LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph-sdk_asyncrunsRunsClientwait
    Method●Since v0.3

    wait

    Copy
    wait(
      self,
      thread_id: str | None,
      assistant_id: str
    View source on GitHub
    ,
    *
    ,
    input
    :
    Input
    |
    None
    =
    None
    ,
    command
    :
    Command
    |
    None
    =
    None
    ,
    metadata
    :
    Mapping
    [
    str
    ,
    Any
    ]
    |
    None
    =
    None
    ,
    config
    :
    Config
    |
    None
    =
    None
    ,
    context
    :
    Context
    |
    None
    =
    None
    ,
    checkpoint
    :
    Checkpoint
    |
    None
    =
    None
    ,
    checkpoint_id
    :
    str
    |
    None
    =
    None
    ,
    checkpoint_during
    :
    bool
    |
    None
    =
    None
    ,
    interrupt_before
    :
    All
    |
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    interrupt_after
    :
    All
    |
    Sequence
    [
    str
    ]
    |
    None
    =
    None
    ,
    webhook
    :
    str
    |
    None
    =
    None
    ,
    on_disconnect
    :
    DisconnectMode
    |
    None
    =
    None
    ,
    on_completion
    :
    OnCompletionBehavior
    |
    None
    =
    None
    ,
    multitask_strategy
    :
    MultitaskStrategy
    |
    None
    =
    None
    ,
    if_not_exists
    :
    IfNotExists
    |
    None
    =
    None
    ,
    after_seconds
    :
    int
    |
    None
    =
    None
    ,
    langsmith_tracing
    :
    LangSmithTracing
    |
    None
    =
    None
    ,
    raise_error
    :
    bool
    =
    True
    ,
    headers
    :
    Mapping
    [
    str
    ,
    str
    ]
    |
    None
    =
    None
    ,
    params
    :
    QueryParamTypes
    |
    None
    =
    None
    ,
    on_run_created
    :
    Callable
    [
    [
    RunCreateMetadata
    ]
    ,
    None
    ]
    |
    None
    =
    None
    ,
    durability
    :
    Durability
    |
    None
    =
    None
    )
    ->
    builtins
    .
    list
    [
    dict
    ]
    |
    dict
    [
    str
    ,
    Any
    ]

    Parameters

    NameTypeDescription
    thread_id*str | None

    the thread ID to create the run on. If None will create a stateless run.

    assistant_id*str

    The assistant ID or graph name to run. If using graph name, will default to first assistant created from that graph.

    inputInput | None
    Default:None

    The input to the graph.

    commandCommand | None
    Default:None
    metadataMapping[str, Any] | None
    Default:None
    configConfig | None
    Default:None
    contextContext | None
    Default:None
    checkpointCheckpoint | None
    Default:None
    checkpoint_duringbool | None
    Default:None
    interrupt_beforeAll | Sequence[str] | None
    Default:None
    interrupt_afterAll | Sequence[str] | None
    Default:None
    webhookstr | None
    Default:None
    on_disconnectDisconnectMode | None
    Default:None
    on_completionOnCompletionBehavior | None
    Default:None
    multitask_strategyMultitaskStrategy | None
    Default:None
    if_not_existsIfNotExists | None
    Default:None
    after_secondsint | None
    Default:None
    langsmith_tracingLangSmithTracing | None
    Default:None
    headersMapping[str, str] | None
    Default:None
    on_run_createdCallable[[RunCreateMetadata], None] | None
    Default:None
    durabilityDurability | 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