Commit Graph
3 Commits
Author SHA1 Message Date
Elior Nataf Lackritz 389b3c1d1f fix(checkpoint-postgres): delete finished subgraph calls and prune each thread on one snapshot
keep_latest now deletes a subgraph call's namespace together with the root
checkpoint the call started from. A checkpointer=True subgraph keeps its
latest checkpoint, since its one namespace holds state across calls, and a
call whose root checkpoint isn't saved yet is left alone.

Each thread is pruned in one REPEATABLE READ transaction that deletes
everything its snapshot sees except the kept checkpoints, so what a run
commits meanwhile survives whatever its ID. Writes go by the checkpoints
deleted, since a run can commit a superstep's writes before its checkpoint.

The per-thread statements live in one generator shared by the sync and
async savers, run unprepared: a cached generic plan checks an = ANY array
one element per row.
2026-10-14 13:40:06 -04:00
Elior Nataf Lackritz b46c897f4f fix(checkpoint-postgres): clear deleted parents and detect JS DeltaChannel threads in prune
keep_latest now clears parent_checkpoint_id on the kept checkpoints whose
parent it deleted, in the same transaction, so their parent_config is None
instead of pointing at a deleted checkpoint.

The DeltaChannel check also matches delta_writes_versioned. LangGraph.js
inlines no channel values, so a thread it wrote at snapshot points shows
neither counters nor inline snapshot markers, but it sets this key on the
threads its DeltaChannel graphs start.

New tests commit a DeltaChannel checkpoint right after the per-thread check
and show the fence keeps everything it rebuilds from.
2026-10-13 14:27:53 -04:00
Elior Nataf Lackritz ed478f23b8 feat(checkpoint-postgres): add prune to PostgresSaver and AsyncPostgresSaver
`delete` removes every checkpoint, write and blob of the given threads.
`keep_latest` keeps the latest checkpoint of each namespace, with its
pending writes and the blobs it references, and deletes everything older,
including blobs only those checkpoints used. Checkpoints saved while the
prune runs are left alone.

`keep_latest` refuses threads that use a DeltaChannel, since a
DeltaChannel rebuilds the latest value from older checkpoints; nothing is
pruned when any requested thread uses one.
2026-10-12 21:26:51 -04:00