fix(sdk): reconnect remote conversation websocket#3987
Merged
Conversation
Co-authored-by: openhands <openhands@all-hands.dev>
Collaborator
|
[Automatic Post]: I have assigned @neubig as a reviewer based on the repository MAINTAINERS file. Thanks in advance for the help! This comment was posted by an AI agent (OpenHands) on behalf of the user. |
neubig
approved these changes
Jul 9, 2026
Member
|
Thanks a bunch, I took a look at the code and did some tests, it seems to be working properly. |
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.
HUMAN:
This fixes a issue in RemoteConversation observed in production: after a transient events WebSocket disconnect, our SDK client stopped receiving live events because
WebSocketCallbackClientexited permanently instead of reconnecting.AGENT:
Why
WebSocketCallbackClientused to exit permanently after anyConnectionClosed. For transient WebSocket closes, aRemoteConversationcould silently stop receiving live events and only catch up later through REST polling or manual reconciliation.Summary
ConnectionClosedfailures with the existing backoff flow instead of exiting the client loop.4001(auth failure) and4004(conversation not found) as non-retryable.Issue Number
Fixes #3983
How to Test
Environment setup:
Targeted WebSocket/reconciliation tests:
Broader remote conversation SDK tests:
Lint/type checks on changed files:
Repo lint target:
Live reconnect smoke test:
I also ran a local smoke script that starts a real
websockets.serve(...)server, sends an initial state update, closes the first connection with code1000, accepts the SDK client's reconnect, sends a second state update, and asserts:state-1andstate-2;on_reconnectran exactly once.The script printed:
Video/Screenshots
N/A. This is SDK transport behavior covered by automated tests and the live reconnect smoke above.
Type
Notes
This PR does not change the agent-server WebSocket API. It uses the existing REST event reconciliation path after reconnect rather than
resend_mode=all/since, avoiding duplicate delivery through user callbacks while still repairing the remote event cache.No docs update: this is an internal SDK transport reliability fix with no user-facing API or configuration changes.