fix(agent): stop reference-only compaction handoff from becoming the active turn - #80696
Closed
HexLab98 wants to merge 2 commits into
Closed
fix(agent): stop reference-only compaction handoff from becoming the active turn#80696HexLab98 wants to merge 2 commits into
HexLab98 wants to merge 2 commits into
Conversation
…active turn After a completed assistant stop, a standalone CONTEXT COMPACTION handoff could occupy the sole user slot and resume stale Historical Task Snapshot work with no new human ask. Guard post-compaction continues, hide standalone handoffs from session dispatch, and harden SUMMARY_PREFIX for the empty-after-handoff case (NousResearch#80622).
Pin NousResearch#80622 invariants: handoff alone must not drive a model call after stop, pending real users are restored, and synthetic compaction rows are never treated as user-originated turns. Also give micro-compaction enough passes to pay back the longer SUMMARY_PREFIX marker overhead.
HexLab98
force-pushed
the
fix/80622-compaction-handoff-active-turn
branch
from
August 7, 2026 01:40
226c14b to
8debae3
Compare
kshitijk4poor
added a commit
that referenced
this pull request
Aug 7, 2026
…ordering, prompt carve-out, honest skip response Follow-ups on top of the salvaged #80696 fix (review findings): - Sibling sites: rollback.restore, gateway /retry, CLI /retry and /undo N, and both CLI resume turn counters now use is_user_originated_turn so legacy-persisted standalone handoffs (durable role=user, no display_kind) can never be truncation targets or counted as user turns (#80622 suggested regression 4, dispatcher-wide). - Site-1 guard: hoist the api_call_count decrement + iteration-budget refund above the break so a skipped turn no longer leaks a budget unit and finalize_turn logs the true call count (matches the ollama early-exit and the site-2 sibling). - Site-2 guard: run the handoff guard BEFORE reanchoring so a restored user ask is what the anchor lands on, not a stale pre-restore index. - SUMMARY_PREFIX: add the mid-tool-loop carve-out the code-side guard already implements, so a literal-minded model doesn't halt an in-flight exchange after in-place compaction. - Skip path returns a short compaction status instead of replaying the previous turn's answer (finalize_turn would append it as a fresh assistant row — duplicate prose in transcript and delivery).
Collaborator
|
Merged via #81070 — both your commits were cherry-picked onto current main with your authorship preserved (rebase-merge), plus two follow-up commits from review: finishing the bug class at 5 more dispatcher sibling sites (rollback.restore, gateway /retry, CLI /retry + /undo, resume counters), refund ordering at guard site 1, a mid-tool-loop carve-out in the new SUMMARY_PREFIX clause, and DB-picker parity in list_recent_user_messages for legacy-persisted handoffs. Thanks for the thorough fix and the byte-frozen prefix generation — that mechanism made the prompt hardening safe to extend. |
This was referenced Aug 7, 2026
ma1138569845
pushed a commit
to ma1138569845/dechnicAuditor-agent
that referenced
this pull request
Aug 10, 2026
…tes, refund ordering, prompt carve-out, honest skip response Follow-ups on top of the salvaged NousResearch#80696 fix (review findings): - Sibling sites: rollback.restore, gateway /retry, CLI /retry and /undo N, and both CLI resume turn counters now use is_user_originated_turn so legacy-persisted standalone handoffs (durable role=user, no display_kind) can never be truncation targets or counted as user turns (NousResearch#80622 suggested regression 4, dispatcher-wide). - Site-1 guard: hoist the api_call_count decrement + iteration-budget refund above the break so a skipped turn no longer leaks a budget unit and finalize_turn logs the true call count (matches the ollama early-exit and the site-2 sibling). - Site-2 guard: run the handoff guard BEFORE reanchoring so a restored user ask is what the anchor lands on, not a stale pre-restore index. - SUMMARY_PREFIX: add the mid-tool-loop carve-out the code-side guard already implements, so a literal-minded model doesn't halt an in-flight exchange after in-place compaction. - Skip path returns a short compaction status instead of replaying the previous turn's answer (finalize_turn would append it as a fresh assistant row — duplicate prose in transcript and delivery).
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
…tes, refund ordering, prompt carve-out, honest skip response Follow-ups on top of the salvaged NousResearch#80696 fix (review findings): - Sibling sites: rollback.restore, gateway /retry, CLI /retry and /undo N, and both CLI resume turn counters now use is_user_originated_turn so legacy-persisted standalone handoffs (durable role=user, no display_kind) can never be truncation targets or counted as user turns (NousResearch#80622 suggested regression 4, dispatcher-wide). - Site-1 guard: hoist the api_call_count decrement + iteration-budget refund above the break so a skipped turn no longer leaks a budget unit and finalize_turn logs the true call count (matches the ollama early-exit and the site-2 sibling). - Site-2 guard: run the handoff guard BEFORE reanchoring so a restored user ask is what the anchor lands on, not a stale pre-restore index. - SUMMARY_PREFIX: add the mid-tool-loop carve-out the code-side guard already implements, so a literal-minded model doesn't halt an in-flight exchange after in-place compaction. - Skip path returns a short compaction status instead of replaying the previous turn's answer (finalize_turn would append it as a fresh assistant row — duplicate prose in transcript and delivery).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
stop, a standalone[CONTEXT COMPACTION — REFERENCE ONLY]role=userhandoff could become the sole active user turn and resume stale Historical Task Snapshot work with no new human ask (Regression: reference-only compaction handoff can become the active turn and resume completed work #80622).SUMMARY_PREFIXfor the empty-after-handoff case and freeze the prior prefix for resume renormalization.Test plan
scripts/run_tests.sh tests/agent/test_reference_handoff_active_turn.py tests/agent/test_summary_prefix_semantics.py tests/agent/test_resume_stale_active_task.py tests/agent/test_summary_prefix_tool_use.pyscripts/run_tests.sh tests/agent/test_compressed_summary_metadata.py tests/agent/test_summary_role_template_alternation.py tests/run_agent/test_compression_boundary_hook.py tests/run_agent/test_compression_persistence.pyfinish_reason=stop), trigger compaction with no follow-up user message, confirm no new tool-calling turn starts from the handoff aloneFixes #80622