fix(app): queue concurrent approval requests instead of overwriting them - #1159
Open
addyCooks wants to merge 1 commit into
Open
fix(app): queue concurrent approval requests instead of overwriting them#1159addyCooks wants to merge 1 commit into
addyCooks wants to merge 1 commit into
Conversation
The three "ask the user" slots each held a single resolver, so a second caller arriving before the first was answered overwrote it and that first promise could never settle. tool-executor starts up to MAX_CONCURRENT_AGENTS subagents in one turn and awaits them with Promise.allSettled, so one stranded caller meant the batch never resolved and the turn never ended. Escape did not help either: the subagent was parked in an await that is not abort-aware, so recovery meant killing the process. Each slot now backs onto a FIFO shared by all three. Requests queue in arrival order, the head is presented, and answering it resolves that caller and promotes the next, so every caller settles exactly once with its own answer. The same single-resolver design backed ask_user and the main agent's tool confirmation, so both are fixed by the same change. Closes Nano-Collective#1156
addyCooks
requested review from
Avtrkrb,
akramcodez and
will-lamerton
as code owners
September 2, 2026 16:57
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.
Closes #1156
Description
The three "ask the user" slots
question-queue,tool-approval-queueandtool-confirm-queueeach stored a single resolver in auseRef. A secondcaller arriving before the first was answered overwrote it, and that first
promise could then never settle.
tool-executorstarts up toMAX_CONCURRENT_AGENTS(5) subagents in one turnand awaits them with
Promise.allSettled, so one stranded caller meant the batchnever resolved and the turn never ended. Escape did not help either: the subagent
was parked in an await that is not abort-aware, so recovery meant killing the
process.
Each slot now backs onto a FIFO shared by all three. Requests queue in arrival
order, the head is presented, and answering it resolves that caller and promotes
the next so every caller settles exactly once with its own answer.
The three blocks were near-identical, so they collapse into one
useHandlerQueuehelper used three times; the change is a net reduction in the file. The hook's
public shape is unchanged, so
App.tsx,chat-input.tsxandinteractive-app.tsxneeded no edits.
Scope
Two items from the issue's suggested fix are deliberately not here:
chat-input.tsxandinteractive-app.tsx. Worth doing, but it is UX on top ofthe fix rather than part of it.
signal(). That changescreateGlobalHandlerSlot'ssignature and every call site, including
subagent-executor.ts:739where thesub-agent tool bridge work for ACP: thread sub-agent tool results back so every call is announced and settles with its real status #1105 is also editing. Queuing alone removes the
hang; abort handling is a clean follow-up once that lands.
Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)Manual Testing
Checklist