LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    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
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph-sdk_asyncthreadsThreadsClientupdate_state
    Method●Since v0.3

    update_state

    Copy
    update_state(
      self,
      thread_id: str,
      values: dict[str, Any] |
    View source on GitHub
    Sequence
    [
    dict
    ]
    |
    None
    ,
    *
    ,
    as_node
    :
    str
    |
    None
    =
    None
    ,
    checkpoint
    :
    Checkpoint
    |
    None
    =
    None
    ,
    checkpoint_id
    :
    str
    |
    None
    =
    None
    ,
    headers
    :
    Mapping
    [
    str
    ,
    str
    ]
    |
    None
    =
    None
    ,
    params
    :
    QueryParamTypes
    |
    None
    =
    None
    )
    ->
    ThreadUpdateStateResponse

    Parameters

    NameTypeDescription
    thread_id*str

    The ID of the thread to update.

    values*dict[str, Any] | Sequence[dict] | None

    The values to update the state with.

    as_nodestr | None
    Default:None
    checkpointCheckpoint | None
    Default:None
    checkpoint_idstr | None
    Default:None
    headersMapping[str, str] | None
    Default:None
    paramsQueryParamTypes | None
    Default:None

    Update the state of a thread.

    client = get_client(url="http://localhost:2024)
    response = await client.threads.update_state(
        thread_id="my_thread_id",
        values={"messages":[{"role": "user", "content": "hello!"}]},
        as_node="my_node",
    )
    print(response)
    
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    {
        'checkpoint': {
            'thread_id': 'e2496803-ecd5-4e0c-a779-3226296181c2',
            'checkpoint_ns': '',
            'checkpoint_id': '1ef4a9b8-e6fb-67b1-8001-abd5184439d1',
            'checkpoint_map': {}
        }
    }

    Update the state as if this node had just executed.

    The checkpoint to update the state of.

    (deprecated) The checkpoint ID to update the state of.

    Optional custom headers to include with the request.

    Optional query parameters to include with the request.