Skip to content

fix(compressor): batch salvage \u2014 orphan tool_calls, cooldown abort flags, system-head summary role (#51225 #52056 #52167) - #208

Merged
hashbender merged 1 commit into
mainfrom
mirror/pr-56197
Jul 1, 2026
Merged

fix(compressor): batch salvage \u2014 orphan tool_calls, cooldown abort flags, system-head summary role (#51225 #52056 #52167)#208
hashbender merged 1 commit into
mainfrom
mirror/pr-56197

Conversation

@hashbender

Copy link
Copy Markdown
Owner

Summary

User-requested batch salvage of three complementary P1 bug fixes to agent/context_compressor.py, rebased onto current main. All three targeted bugs are confirmed still present on main; the three fixes touch non-overlapping regions and compose cleanly.

Note: the original PR branches predated a since-landed cooldown-helper refactor (_record_/_clear_compression_failure_cooldown), so their raw diffs would have reverted that refactor. This salvage re-applies only the genuine fix intent on top of current main's helper-based code — the refactor is left intact (verified).

Included PRs (authorship preserved per commit)

Follow-up commit (mine)

  • test(compressor): tidy blank-line spacing + assert placeholder never overwrites text — review-driven test cleanup only, no production change.

Verification

  • pytest tests/agent/test_context_compressor.py141 passed (includes 8 new tests across TestSanitizerStripsOrphanedToolCalls, TestCooldownReentryAbort, TestDoubleCompactionSummaryRole).
  • Mutation-checked: reverting each of the three source fixes fails its corresponding tests — the tests are genuine behavior contracts, not change-detectors.
  • Stale-revert check: the cooldown-helper refactor is intact (no raw _summary_failure_cooldown_until assignments reintroduced in compress()/_generate_summary).

Closes NousResearch#51225. Closes NousResearch#52056. Closes NousResearch#52167.

Co-authored-by: liuhao1024 sunsky.lau@gmail.com
Co-authored-by: srojk34 286497132+srojk34@users.noreply.github.com


Mirror-of: NousResearch#56197
NousResearch#56197

@tenki-reviewer

tenki-reviewer Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Complete
No issues found!

Risk: 🟠 High (78/100) — no findings · 564 LOC across 2 files


The compression summary is silently dropped when _force_user_leading=True coincides with the Causal Coupling guard pushing compress_end to the end of the message list, causing data loss — the entire conversation after the system prompt is lost.

Files Reviewed (2 files)
agent/context_compressor.py
tests/agent/test_context_compressor.py

@hashbender
hashbender merged commit 66a830a into main Jul 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant