mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
fix(compression): let handoff-strip supersede the head-copy skip
The summary_idx head-copy skip (from #69302) dropped the entire merged handoff message, deleting the genuine prior-tail user content that #47274's _strip_context_summary_handoff_message correctly unwraps. Strip handles both shapes: standalone handoffs drop, merged handoffs keep their real content. Caught by test_recompression_of_current_merged_handoff_preserves_prior_tail_once when both PRs landed together.
This commit is contained in:
parent
2b84ed921c
commit
5a3ee3c537
1 changed files with 9 additions and 13 deletions
|
|
@ -4040,19 +4040,15 @@ This compaction should PRIORITISE preserving all information related to the focu
|
|||
# Phase 4: Assemble compressed message list
|
||||
compressed = []
|
||||
for i in range(compress_start):
|
||||
# If an earlier compaction handoff is in the protected head
|
||||
# (common after resume / in-place compaction), do not carry it
|
||||
# forward verbatim. It has already been rehydrated into
|
||||
# _previous_summary above and _generate_summary() will emit the
|
||||
# updated replacement below. Keeping both makes repeated
|
||||
# compactions accumulate old summaries and prevents the live prompt
|
||||
# from actually shrinking.
|
||||
if (
|
||||
summary_idx is not None
|
||||
and i == summary_idx
|
||||
and self._is_context_summary_content(messages[i].get("content"))
|
||||
):
|
||||
continue
|
||||
# An earlier compaction handoff in the protected head (common
|
||||
# after resume / in-place compaction) must not be carried forward
|
||||
# verbatim — it is already rehydrated into _previous_summary and
|
||||
# _generate_summary() emits the updated replacement below.
|
||||
# _strip_context_summary_handoff_message() handles both shapes:
|
||||
# standalone handoffs strip to None (dropped), merged handoffs
|
||||
# unwrap to their genuine prior-tail content (preserved). Do NOT
|
||||
# short-circuit on summary_idx here: a merged handoff carries real
|
||||
# user content that a blanket skip would silently delete.
|
||||
msg = _fresh_compaction_message_copy(messages[i])
|
||||
if i == 0 and msg.get("role") == "system":
|
||||
existing = msg.get("content")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue