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_syncrunsSyncRunsClientcancel
    Methodā—Since v0.3

    cancel

    Copy
    cancel(
      self,
      thread_id: str,
      run_id: str,
      *,
      wait: bool 
    View source on GitHub
    =
    False
    ,
    action
    :
    CancelAction
    =
    'interrupt'
    ,
    headers
    :
    Mapping
    [
    str
    ,
    str
    ]
    |
    None
    =
    None
    ,
    params
    :
    QueryParamTypes
    |
    None
    =
    None
    )
    ->
    None

    Parameters

    NameTypeDescription
    thread_id*str

    The thread ID to cancel.

    run_id*str

    The run ID to cancel.

    waitbool
    Default:False

    Whether to wait until run has completed.

    actionCancelAction
    Default:'interrupt'
    headersMapping[str, str] | None
    Default:None
    paramsQueryParamTypes | None
    Default:None

    Get a run.

    client = get_sync_client(url="http://localhost:2024")
    client.runs.cancel(
        thread_id="thread_id_to_cancel",
        run_id="run_id_to_cancel",
        wait=True,
        action="interrupt"
    )

    Action to take when cancelling the run. Possible values are interrupt or rollback. Default is interrupt.

    Optional custom headers to include with the request.

    Optional query parameters to include with the request.