Prune LangGraph checkpoints per thread and delete them with the conversation #85
Reference in New Issue
Block a user
Delete Branch "perf/prune-checkpoints"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The SQLite checkpointer stores a full conversation snapshot on every graph step and nothing pruned old ones (about 1.6 MB per checkpoint at 200 turns). Deleting a conversation also left its thread behind.
CHECKPOINT_KEEP_PER_THREAD(default 20) checkpoints of that thread are kept, plus their pending writes. It runs under the saver's own lock, so it never races a checkpoint write. State reads only use the newest checkpoint, and a test confirmsaget_statestill returns all 50 messages after pruning 25 turns down to 5. Measured at about 2 ms for a 200-checkpoint thread, so it runs inline. Invalid or< 1values fall back to 20 with a warning.CHECKPOINT_KEEP_PER_THREADis in.env.exampleanddocker-compose.yml.Out of scope: base64 images are still stored inside checkpoints.
Review: Sonnet worker plus two review rounds. Round 1 added the missing tests and env wiring, guarded against bad values, and asked for a latency measurement. Round 2 was clean.
🤖 Generated with Claude Code