fix: make the compact boundary hold and its instruction arrive - #111
Merged
Conversation
…n runs planner_request_compact fires ctx.compact() and returns text asking the model not to continue. Nothing enforced it. In one measured session the model cleared the boundary immediately and walked the whole of finalize — doubt review, verification, final summary, through to done — while summarization was still running. compact_before_doubt exists so the audit reads persisted artifacts instead of live confidence; run that way it achieved the exact opposite, and none of those four minutes reached the session file, because the SDK disconnects the session from agent events for the duration of a compaction. The exit gate now refuses complete_compact while a compaction this extension asked for is in flight. The flag is passed in rather than read from a module: whether a compaction is running is the host's knowledge, and the planner's own recovery paths must be able to release a boundary precisely when one IS in flight — they omit the flag and say why. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
deliverAs:"followUp" is a streaming mode. The agent loop drains that queue only where it would otherwise stop, so with no run in flight the message is not queued behind anything — it sits in the input queue as if the user had typed it and never pressed enter. A planner-controlled compaction aborts the run on its way in, so the post-compact instruction landed in exactly that state. One measured session sat two hours waiting for a keypress. Follow-up delivery still exists for the reason it was introduced — a compaction that finishes late must not interrupt the run it landed in — so the choice is now made rather than assumed, in one place all three senders share. Where idle is unknown (the watchdog before its first event) the guess is "running": delivered late beats not delivered, and the same reasoning covers the race, so a turn refused by a run that just started falls back to the queue. enqueuePlannerPostCompactMessage had taken isIdle since it was written and ignored it; hasPendingMessages was never used at all and is gone. Both compact-path sends now happen on the next macrotask. compact() disconnects the session from agent events for its whole duration and reconnects in a `finally` that has not run when session_compact fires — a turn started inside the handler would run against a session that is not listening, which is how four minutes of work went missing from the session file. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… gate does The rescue exists to unfreeze a compact boundary that neither completed nor errored, and to do that it bypasses the idle gate entirely. Every reason that gate would have refused for therefore has to be restated, or it is silently lost — and it named only `broken` and `requiresUserDecision`, which leaves out the rest of "the next move is the user's". The done stage sets no flag at all; it is recognised only through isPlannerWaitingOnUser, which is what the post-compact enqueue already consults. A boundary pending at goal approval or awaiting acceptance would have woken the model there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ue gate Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
No description provided.