| Name | Type | Description |
|---|---|---|
thread_id* | str | None | the thread ID to create the run on.
If |
assistant_id* | str | The assistant ID or graph name to run. If using graph name, will default to first assistant created from that graph. |
input | Input | None | Default: NoneThe input to the graph. |
command | Command | None | Default: None |
metadata | Mapping[str, Any] | None | Default: None |
config | Config | None | Default: None |
context | Context | None | Default: None |
checkpoint | Checkpoint | None | Default: None |
checkpoint_during | bool | None | Default: None |
interrupt_before | All | Sequence[str] | None | Default: None |
interrupt_after | All | Sequence[str] | None | Default: None |
webhook | str | None | Default: None |
on_disconnect | DisconnectMode | None | Default: None |
on_completion | OnCompletionBehavior | None | Default: None |
multitask_strategy | MultitaskStrategy | None | Default: None |
if_not_exists | IfNotExists | None | Default: None |
after_seconds | int | None | Default: None |
langsmith_tracing | LangSmithTracing | None | Default: None |
headers | Mapping[str, str] | None | Default: None |
on_run_created | Callable[[RunCreateMetadata], None] | None | Default: None |
durability | Durability | None | Default: None |
Create a run, wait until it finishes and return the final state.
client = get_client(url="http://localhost:2024")
final_state_of_run = await client.runs.wait(
thread_id=None,
assistant_id="agent",
input={"messages": [{"role": "user", "content": "how are you?"}]},
metadata={"name":"my_run"},
context={"model_name": "anthropic"},
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
webhook="https://my.fake.webhook.com",
multitask_strategy="interrupt"
)
print(final_state_of_run)
-------------------------------------------------------------------------------------------------------------------------------------------
{
'messages': [
{
'content': 'how are you?',
'additional_kwargs': {},
'response_metadata': {},
'type': 'human',
'name': None,
'id': 'f51a862c-62fe-4866-863b-b0863e8ad78a',
'example': False
},
{
'content': "I'm doing well, thanks for asking! I'm an AI assistant created by Anthropic to be helpful, honest, and harmless.",
'additional_kwargs': {},
'response_metadata': {},
'type': 'ai',
'name': None,
'id': 'run-bf1cd3c6-768f-4c16-b62d-ba6f17ad8b36',
'example': False,
'tool_calls': [],
'invalid_tool_calls': [],
'usage_metadata': None
}
]
}A command to execute. Cannot be combined with input.
Metadata to assign to the run.
The configuration for the assistant.
Static context to add to the assistant.
The checkpoint to resume from.
(deprecated) Whether to checkpoint during the run (or only at the end/interruption).
Nodes to interrupt immediately before they get executed.
Nodes to Nodes to interrupt immediately after they get executed.
Webhook to call after LangGraph API call is done.
The disconnect mode to use. Must be one of 'cancel' or 'continue'.
Whether to delete or keep the thread created for a stateless run. Must be one of 'delete' or 'keep'.
Multitask strategy to use. Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
How to handle missing thread. Defaults to 'reject'. Must be either 'reject' (raise error if missing), or 'create' (create new thread).
The number of seconds to wait before starting the run. Use to schedule future runs.
LangSmith tracing configuration. Allows routing traces to a specific project or associating with a dataset example.
Optional custom headers to include with the request.
Optional callback to call when a run is created.
The durability to use for the run. Values are "sync", "async", or "exit". "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps