Skip to content

fix: make the compact boundary hold and its instruction arrive - #111

Merged
m62624 merged 4 commits into
mainfrom
fix/compact-boundary-and-followup
Jul 27, 2026
Merged

fix: make the compact boundary hold and its instruction arrive#111
m62624 merged 4 commits into
mainfrom
fix/compact-boundary-and-followup

Conversation

@m62624

@m62624 m62624 commented Jul 27, 2026

Copy link
Copy Markdown
Owner

No description provided.

m62624 and others added 4 commits July 27, 2026 13:51
…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>
@github-actions github-actions Bot added the fix label Jul 27, 2026
@m62624
m62624 merged commit 28b4fa4 into main Jul 27, 2026
6 checks passed
@m62624
m62624 deleted the fix/compact-boundary-and-followup branch July 27, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant