Skip to content

fix(compaction): mark end of context summary in role=user fallback (salvage #17121) - #20169

Merged
teknium1 merged 2 commits into
mainfrom
salvage/pr-17121
May 5, 2026
Merged

fix(compaction): mark end of context summary in role=user fallback (salvage #17121)#20169
teknium1 merged 2 commits into
mainfrom
salvage/pr-17121

Conversation

@teknium1

@teknium1 teknium1 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Salvages @wmagev's PR #17121 onto current main (trivial test-file conflict with newer sanitizer test resolved — both tests now land).

What it does

When compaction's standalone-summary path picks role="user" (head ends with assistant/tool), the body's verbatim ## Active Task quote gets read as fresh user input by weak/local models (#11475, #14521). The merge-into-tail path already appends an --- END OF CONTEXT SUMMARY --- marker; this mirrors it on the standalone path so both routes give the same signal.

Changes

  • agent/context_compressor.py — append end-of-summary marker when summary_role == 'user' and we're not merging into tail.
  • tests/agent/test_context_compressor.py — new test_user_role_summary_carries_end_marker.
  • scripts/release.py — AUTHOR_MAP entry for wmagev.

Validation

tests/agent/test_context_compressor.py — 68 passed locally.

Closes #17121 via salvage.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint labels May 5, 2026
@teknium1
teknium1 force-pushed the salvage/pr-17121 branch from 036e334 to 2f534c6 Compare May 5, 2026 11:45
wmagev and others added 2 commits May 5, 2026 04:51
When the head ends with assistant/tool and the tail starts with assistant,
the summary is inserted as a standalone role="user" message. The body's
verbatim "## Active Task" quote then gets read as fresh user input by
weak/local models (#11475, #14521).

The merge-into-tail path already appends an explicit end-of-summary marker
for this reason. Mirror it on the standalone path so both insertion routes
give the model the same "summary above, not new input" signal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants