fix(compression): append END OF CONTEXT SUMMARY marker to all standalone summaries (salvages #33346)#45153
Conversation
…dalone summaries regardless of role When the compression summary lands as an assistant-role message (head ends with user), the end marker was not appended. Models may regurgitate the summary text as their own visible output when there's no clear boundary signal (#33256). The end marker was already appended for user-role summaries (#11475, #14521) but the assistant-role path was missed in the original fix. This ensures ALL standalone summary messages carry the boundary marker, preventing summary text from leaking into user-visible chat output.
…ip it on rehydration Follow-up to the #33346 cherry-pick: - the marker string was duplicated at both insertion sites (standalone + merged-into-tail); hoist to a module constant - _strip_summary_prefix now also strips a trailing end marker so a rehydrated handoff body doesn't leak the boundary directive into the iterative-update summarizer prompt (it is re-appended on insertion)
|
Verified clean — compression END OF CONTEXT SUMMARY marker for all roles Reviewed the marker propagation across all three insertion paths:
No issues found. |
Summary
The "END OF CONTEXT SUMMARY" boundary marker is now appended to every standalone compaction summary regardless of role — previously only
role="user"summaries got it, so an assistant-role summary could be regurgitated verbatim by the model as its own reply (#33256).Closes #33256.
Changes
agent/context_compressor.py: drop thesummary_role == "user"gate on the end marker (from fix(compression): append END OF CONTEXT SUMMARY marker to all standalone summaries (#33256) #33346 by @Tranquil-Flow, + his 4 regression tests)_SUMMARY_END_MARKERmodule constant (was duplicated at the standalone + merged-into-tail sites);_strip_summary_prefixnow also strips a trailing marker so rehydrated handoff bodies don't leak the boundary directive into the iterative-update summarizer promptValidation
Attribution
Salvages #33346 by @Tranquil-Flow — cherry-picked with authorship preserved; rebase-merge to keep per-commit credit.
Infographic