fix(agent): retire stale todo snapshots after completion - #89910
fix(agent): retire stale todo snapshots after completion#89910eventh0riz0n wants to merge 1 commit into
Conversation
Reviewed the diff. Carefully engineered retirement semantics: an authoritative-but-completed store now clears prior snapshots instead of resurrecting finished work, while genuinely empty stores (fresh gateway agents that cannot rehydrate post-compaction) keep theirs; deletion of standalone synthetic rows triggers _repair_message_sequence so assistant alternation survives, mixed rows are stripped in place and their synthetic provenance flag cleared, every content rewrite drops the stale api_content sidecar, and unknown/raising stores fail conservative. The test set covers each branch including the tricky middle-of-history deletion and multimodal part survival.
No blocking issues found. |
Summary
api_content, provenance, or strict role alternation.Motivation and Context
After context compression, a previously injected todo snapshot could survive even after every persisted task was completed or cancelled. A later turn could then treat finished work as active again.
This extends the retained-todo behavior introduced in #69860: pending tasks are still preserved, while an authoritative completed/cancelled store now retires the old snapshot safely. This PR does not close #69860.
Related work and scope
How Has This Been Tested?
Red control on an unmodified
origin/mainwith the new regressions applied:Green verification on this branch:
A separate final read-only review exercised 94 relevant tests and found no HIGH, MEDIUM, or LOW findings.
Test Configuration
Types of Changes
Checklist
pytest tests/ -qand all tests passScreenshots / Logs
Not applicable.
Reviewer Notes
The key compatibility guard is intentional:
TodoStore.has_items() == Falsedoes not authorize deleting a retained snapshot, because an empty/unhydrated store cannot prove that the snapshot is stale. Only a non-empty authoritative store whose active rendering is empty retires it.