fix(busy-state): release attachManager on /abort + periodic reconciliation#122
Closed
avfirsov wants to merge 1 commit into
Closed
fix(busy-state): release attachManager on /abort + periodic reconciliation#122avfirsov wants to merge 1 commit into
avfirsov wants to merge 1 commit into
Conversation
…ation Two independent busy trackers (attachManager and foregroundSessionState) were being released asymmetrically: session.idle and /detach both call markAttachedSessionIdle + clearPromptResponseMode, but /abort cleared only foregroundSessionState. The bot would then wedge with "agent is busy" forever because the busy-guard ORs both trackers. Changes: - abort.ts: call markAttachedSessionIdle + clearPromptResponseMode in the success path (after server-confirmed idle) and as a safety net in the error/timeout paths, so a transient failure cannot permanently wedge the bot. - index.ts: add a 15s busyReconciliationTimer that calls reconcileBusyState independently of the SSE stream. Previously reconciliation only fired on server.heartbeat SSE events, so a dead stream killed reconciliation too. The function has its own 10s throttle, so the 15s tick respects it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
|
I think timer is not a geood idea there, I prepaired another fix e80cbcf |
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.
Problem
Two independent busy trackers —
attachManagerandforegroundSessionState— were being released asymmetrically.session.idleand/detachboth callmarkAttachedSessionIdle+clearPromptResponseMode, but/abortcleared onlyforegroundSessionState. Sincebusy-guardORs both trackers, the bot would then wedge on the next prompt with «agent is busy» until a process restart.Pattern table
session.idle/detach/abort(before)markAttachedSessionIdle()clearPromptResponseMode()foregroundSessionState.markIdle()assistantRunState.clearRun()Changes
src/bot/commands/abort.ts— callmarkAttachedSessionIdle+clearPromptResponseMode:session.idleand/detach;abortError/AbortError(timeout) paths — even when the server does not confirm the abort, a transient network failure should not permanently wedge the bot.src/bot/index.ts— add a 15-secondbusyReconciliationTimer.reconcileBusyState()already exists and is correct (it pollssession.status()and resets stale busy), but it was only invoked from theserver.heartbeatSSE event. If the SSE stream silently dies, reconciliation dies with it. The timer runs independently of SSE and naturally respects the function's ownRECONCILE_MIN_INTERVAL_MS=10sthrottle.Test plan
npm run buildclean (verified locally)/abort→ send next prompt → should accept (not «agent busy»)opencode serve→ restart it → bot should recover via the new timer without manual intervention