fix(agent): stop compaction summaries hijacking the current task (salvages #44345 + #41650)#44454
Conversation
The prompt consolidation above retires the carveout-era prefix. Without a frozen copy in _HISTORICAL_SUMMARY_PREFIXES, summaries persisted by pre-upgrade builds would lose detection (_is_context_summary_content) and renormalization (_strip_summary_prefix) — the exact regression class the tuple exists to prevent. Adds contract tests covering every frozen prefix. Refs #41607 #38364 #42812
🔎 Lint report:
|
Verification: Compaction Summary Prefix HardeningThis is a well-structured fix. Verified:
Clean fix, no issues found. |
…erences Legibility pass on the consolidated prefix: collapse the topic-overlap rule from three overlapping sentences into one WINS sentence + one discard/no-wrap-up sentence (same constraints, less dilution), fix the module docstring to describe the headings that actually shipped, and correct the #10896 comment's heading name (Historical Pending User Asks).
Summary
Compaction summaries can no longer hijack the current task: the "consistent → use as background" carveout in SUMMARY_PREFIX is removed, all summary sections are framed as historical (DO NOT EXECUTE), and the retired prefix is frozen so pre-upgrade sessions keep summary detection.
Root cause: SUMMARY_PREFIX licensed the model to treat the stale summary as active context whenever the latest user message was "consistent" with the old Active Task — so topic overlap resumed dead work (#41607), vague follow-ups got scope-expanded from old "Remaining Work" sections (#38364), and idle-resumed sessions re-executed stale Active Tasks (#42812).
Closes #41607. Closes #38364. Closes #42812.
Changes
agent/context_compressor.py: heading constants (HISTORICAL_*) replace actionable section names across all 3 template sites (deterministic fallback, LLM template, iterative-update prompt) — from fix(agent): frame compaction handoff sections as historical context #44345 by @konsisumeragent/context_compressor.py: SUMMARY_PREFIX carveout removed; topic overlap explicitly does NOT mean resume — from fix(agent): strengthen compression preamble vs stale tasks (#41607) #41650 by @kyssta-exe (merged with the heading constants)agent/context_compressor.py: carveout-era prefix frozen into_HISTORICAL_SUMMARY_PREFIXES(neither contributor PR did this; without it, summaries persisted by current builds lose detection/renormalization after upgrade)test_no_background_consistency_carveout,test_replaced_prefixes_are_frozen_for_renormalization— exercises detection + strip for every frozen prefix)Validation
pytest tests/agent/ -k "compress or summary or compaction"Attribution
Salvages #44345 (@konsisumer, base) and #41650 (@kyssta-exe, carveout removal) — both cherry-picked with authorship preserved; rebase-merge to keep per-commit credit. Supersedes #41634 and #38368.
Infographic