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

    Chat LangChain

    What can I help with?

    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.checkpoint.postgresPostgresSaverprune
    Method●Since v3.2

    prune

    Copy
    prune(
      self,
      thread_ids: Sequence[str],
      *,
      strategy: str = 'keep_latest'
    
    View source on GitHub
    )
    ->
    None

    Parameters

    NameTypeDescription
    thread_ids*Sequence[str]
    strategystr
    Default:'keep_latest'

    Prune checkpoints for the given threads.

    "delete" removes every checkpoint, write and blob of the threads, in one transaction.

    "keep_latest" keeps the latest checkpoint of each namespace (the one get_tuple loads, plus its parent when it predates v4 and has pending sends), with its pending writes and the blobs it references, and deletes the rest. A kept checkpoint whose parent it deletes is left with no parent. A subgraph call's namespace is deleted with the root checkpoint the call started from, except a checkpointer=True subgraph's, which keeps its latest checkpoint. Each thread is pruned in its own transaction, on one snapshot of it, so a run appending to the thread meanwhile is safe; forking or replaying from a checkpoint being deleted is not. A thread that fails because another transaction changed it leaves the threads before it pruned, and retrying is safe.

    "keep_latest" refuses threads that use a DeltaChannel, since it rebuilds the latest value from older checkpoints: if any requested thread does, nothing is pruned. A thread that starts using one before its turn in the batch is refused then, after the threads before it.

    The thread IDs to prune.

    "keep_latest" or "delete".