fix(acp): drop untracked non-numeric responses to prevent grok handshake stall#6
Merged
Merged
Conversation
…ake stall The RpcClient and raw ext requests only ever mint numeric request ids, so a response whose id is not a base-10 number cannot match anything we sent. Some agents (notably grok) emit unsolicited JSON-RPC responses with symbolic ids such as "skills-reload" right after `initialize`. Forwarding those to the RpcClient made it fail while resolving the id, tearing down the response loop so that subsequent `authenticate` and `session/new` responses were never delivered and the handshake stalled until the caller timed out. Route untracked responses through a `forwardUntrackedResponse` guard that only forwards ids matching `^[0-9]+$` and otherwise drops them with a debug log. Applies to both the exit-encoded and success/defect response paths. Adds an in-memory regression test that floods the stream with `skills-reload` responses after `initialize` and asserts the initialize/authenticate/session handshake still completes. Co-Authored-By: Claude Opus 4.8 <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.
Summary
The
RpcClientand raw ext requests only ever mint numeric request ids, so a response whose id isn't a base-10 number cannot match anything we sent. Some agents — notably grok — emit unsolicited JSON-RPC responses with symbolic ids such as"skills-reload"immediately afterinitialize. Forwarding those to theRpcClientmade it fail while resolving the id, which tore down its response loop. The subsequentauthenticateandsession/newresponses were then never delivered and the handshake stalled until the caller timed out.Changes
forwardUntrackedResponseguard in the patched ACP protocol that only forwards responses whose id matches^[0-9]+$; anything else is dropped with a debug log.Tests
grok-skills-reload.test.ts: an in-memory fake grok peer answersinitializeand then floods the stream with untrackedskills-reloadresponses; the test asserts theinitialize→authenticate→session/newhandshake still completes.🤖 Generated with Claude Code