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

    cancel_many

    Copy
    cancel_many(
      self,
      *,
      thread_id: str | None = None,
      run_ids: Sequence[
    View source on GitHub
    str
    ]
    |
    None
    =
    None
    ,
    status
    :
    BulkCancelRunsStatus
    |
    None
    =
    None
    ,
    action
    :
    CancelAction
    =
    'interrupt'
    ,
    headers
    :
    Mapping
    [
    str
    ,
    str
    ]
    |
    None
    =
    None
    ,
    params
    :
    QueryParamTypes
    |
    None
    =
    None
    )
    ->
    None

    Parameters

    NameTypeDescription
    thread_idstr | None
    Default:None

    The ID of the thread containing runs to cancel.

    run_idsSequence[str] | None
    Default:None

    List of run IDs to cancel.

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

    Cancel one or more runs.

    Can cancel runs by thread ID and run IDs, or by status filter.

    client = get_client(url="http://localhost:2024")
    # Cancel all pending runs
    await client.runs.cancel_many(status="pending")
    # Cancel specific runs on a thread
    await client.runs.cancel_many(
        thread_id="my_thread_id",
        run_ids=["run_1", "run_2"],
        action="rollback",
    )

    Filter runs by status to cancel. Must be one of "pending", "running", or "all".

    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.