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.checkpointbaseBaseCheckpointSaverprune
    Method●Since v4.0

    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.

    Custom implementations must be DeltaChannel-aware. DeltaChannel stores only a sentinel in channel_values for non-snapshot steps; reconstruction walks the parent chain via get_delta_channel_history, accumulating rows from checkpoint_writes until it reaches an ancestor whose channel_values contains a _DeltaSnapshot blob (written every snapshot_frequency updates).

    A naive "keep_latest" that drops intermediate checkpoints and their writes can sever that chain: the surviving "latest" checkpoint is rarely a snapshot point itself, so its delta channels would silently reconstruct as empty (no error raised — get_delta_channel_history simply returns no seed). Safe options when the graph uses DeltaChannel:

    • Walk back from each kept checkpoint and preserve every ancestor (plus its checkpoint_writes) up to the nearest one whose channel_values already contains a _DeltaSnapshot for every DeltaChannel-backed key.
    • Force a fresh snapshot on the kept checkpoint before deleting ancestors — rewrite channel_values[k] = _DeltaSnapshot(value) for each delta channel k (resolving value via the existing ancestor walk first), then prune.
    • Skip pruning threads whose graph uses DeltaChannel until one of the above is implemented.

    The thread IDs to prune.

    The pruning strategy. "keep_latest" retains only the most recent checkpoint per namespace. "delete" removes all checkpoints.