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

    prune

    Copy
    prune(
      self,
      thread_ids: Sequence[str],
      *,
      strategy: PruneStrategy = 'delete'
    View source on GitHub
    ,
    headers
    :
    Mapping
    [
    str
    ,
    str
    ]
    |
    None
    =
    None
    ,
    params
    :
    QueryParamTypes
    |
    None
    =
    None
    )
    ->
    dict
    [
    str
    ,
    Any
    ]

    Parameters

    NameTypeDescription
    thread_ids*Sequence[str]

    List of thread IDs to prune.

    strategyPruneStrategy
    Default:'delete'

    The prune strategy. "delete" removes threads entirely. "keep_latest" prunes old checkpoints but keeps threads and their latest state. Defaults to "delete".

    headersMapping[str, str] | None
    Default:None
    paramsQueryParamTypes | None
    Default:None

    Prune threads by ID.

    client = get_client(url="http://localhost:2024")
    result = await client.threads.prune(
        thread_ids=["thread_1", "thread_2"],
    )
    print(result)  # {'pruned_count': 2}

    Optional custom headers to include with the request.

    Optional query parameters to include with the request.