Repository navigation
Conversation
When the input closed the connection, messages already received were dropped before reaching their handlers. Keep dispatching them; a local close() still stops dispatch. Fixes agentclientprotocol#346 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RaizxxJBbHnYoG9L4g1u5b
close() is a no-op again once the connection is closed, so the SDK's own close() calls after end of input (runUntil, failed writes, onConnect errors) no longer drop the peer's last notifications. Internal failures close the connection without counting as a local close, and in-process app pairs pass a peer's close along as end of input. Requests received before the close are dropped: no response can reach the peer. Errors from notifications dispatched after the close are logged again.
benbrandt
enabled auto-merge (squash)
November 17, 2026 15:16
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 #346.
When the input ends,
receive()closes the connection, andprocessIncomingMessage()stops dispatching as soon as the connection is aborted. Messages received just before the end, whose dispatch had not reached their handler yet, were dropped, so a peer's last notifications were lost.With this change, notifications received before the connection closed are still dispatched, unless local code closed it with
close():close()does nothing once the connection is closed, as before. The SDK's own paths that close after end of input (runUntil/connectWith, failed writes,onConnecterrors) no longer drop the peer's last notifications. Internal failures close the connection without counting as a local close.fs/write_text_fileorterminal/createshould not run for a peer that is gone.client.connect(agentApp)) pass a peer's close along as if the peer ended its stream, so they behave like stream transports.closedandsignaldocs note that notifications can still reach their handlers after the connection closes.Tests:
src/core/jsonrpc.test.ts("JSON-RPC end of input"): delivery after end of input and after a read failure, requests dropped,close()after end of input,connectWith, a pending write failing after end of input, error logging, and a localclose()still dropping notifications.src/v1/acp.test.tsandsrc/v2/acp.test.ts: an agent's last notification reaches a client handler behind 20 other handlers, over a stream withconnectWithand in process.npm run checkpasses.🤖 Generated with Claude Code
https://claude.ai/code/session_01RaizxxJBbHnYoG9L4g1u5b