Fix synthetic auth before replayed user echo - #989
Open
apexphere wants to merge 1 commit into
Open
Conversation
apexphere
marked this pull request as ready for review
August 12, 2026 13:47
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.
Fixes #988.
What changed
When the SDK's synthetic login assistant frame arrives before the replayed user echo, bind the first unsettled queued turn before reporting
auth_required. This lets the existing failure path terminalize the prompt Promise instead of only publishing a session-scoped failure.Adds an upstream-only deterministic regression with a paused synthetic SDK stream. It proves the auth frame was consumed before checking the Promise, then cancels for cleanup and verifies no active turn, queued turn, pending orphan count, or orphan map entry remains.
Root cause
activeTurnwas established only by the replayed user echo. The synthetic auth branch could run first and call the failure helper with no active turn, leaving the queued prompt pending indefinitely.Impact
ACP clients receive a terminal authentication-required outcome for the submitted prompt regardless of whether the SDK replays the user echo before or after its synthetic auth frame.
Validation
npm test -- --run src/tests/acp-agent.test.ts: 375 passed, 9 skipped.npm run check: ESLint and Prettier passed.