Repository navigation
Conversation
Since #6709 the session socket reads client frames before subscribe_to_events returns, so an ErrorFrame for an invalid frame sent while a step holds the state lock could reach the client before sync. The writer now holds reply frames until sync, the replay and the live flush are queued, then releases them in order. Valid messages are still read and saved from connect. Fixes #6745 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwLxahRVqe2sFw9ukc5
Contributor
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Contributor
Coverage Report •
|
||||||||||||||||||||
1 of 5 tasks
all-hands-bot
approved these changes
Nov 13, 2026
all-hands-bot
left a comment
Collaborator
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Scope: this belongs here. The session socket's frame ordering is agent-server behavior this repository owns; no cross-layer change is needed (frame schemas, the OpenAPI contract, and the TypeScript client are untouched, and the fix restores the ordering SyncFrame already documents: sent once, before any replay).
The fix is sound and minimal:
hold_replies()runs before_inbound_loopstarts, so no error reply can bypass the hold;release_replies()is reached on the only path where the connection stays open (aftersync, theafter_seqreplay, and thego_liveflush), and every early-return path closes the writer, so no reply is ever stranded on a live connection.- Ordering holds by construction:
_queueis drained by exactly one writer task, and bothsendandrelease_repliesare synchronous, so there is no interleaving window on the event loop. - Held replies count against the same
MAX_PENDING_BYTESbudget (incremented before the held/queued branch and decremented once on drain), so an invalid-frame flood while a step holds the state lock still trips the existingslow_consumerprotection instead of growing memory unboundedly — consistent with the writer's documented overflow policy. - The #6709 semantics are preserved: inbound frames are still read from connect and
_deliverstill shieldssend_message, so a message sent during a step is saved even if the client leaves. The two #6709 regression tests pass.
Evidence:
- New regression test drives the real
session_socketcoroutine, real_ConnectionWriter, and real_inbound_loop(only auth and the service getter are patched), and its failure mode mirrors production:LocalConversation.send_messagerejects non-user messages with exactly thatAssertionError. It asserts no frame is emitted while the lock is held, thensync→durable→errorafter release. The PR reports it fails on the reverted fix (error already on the wire while subscribe was blocked) and passes with it; I verified the same on this head. uv run pytest -q tests/agent_server/test_session_socket.py tests/agent_server/test_event_socket_races.py tests/agent_server/test_event_router_websocket.py tests/agent_server/test_agent_server_wsproto.py tests/agent_server/test_websocket_first_message_auth.py tests/agent_server/test_sockets_service_getters.py→ 99 passed locally on27f9c06.- All 49 GitHub Actions checks pass on this exact head, including agent-server-tests, agent-server-stress-tests, cross-tests, and the REST API / OpenAPI checks.
No material findings. ✅ APPROVED
VascoSch92
approved these changes
Nov 16, 2026
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:
Engel Nyst (@enyst) set up a daily automation that keeps the verify-agent-server and verify-sdk feature maps current. This PR fixes a bug its run for main@5ff99f1 found.
AGENT:
I'm an AI agent helping Engel Nyst (@enyst) with project work.
Why
Since #6709,
/sockets/session/{conversation_id}reads client frames from connect, beforesubscribe_to_eventsreturns (it waits for the conversation state lock). An invalid inbound frame (for examplerole: "assistant") sent while a step holds the lock got itserrorframe queued at once, so it reached the client beforesync. Clients that treatsyncas the start of the stream (cursor bookkeeping,through_seq) saw a frame before it.Summary
_ConnectionWritercan hold "reply" frames (hold_replies/release_replies); held replies count against the same pending-bytes budget.session_socketholds replies from connect and releases them right aftersync, the replay (whenafter_seqis given) andgo_liveare queued;_inbound_loopsends itsErrorFrames as replies. Inbound frames are still read from connect, so fix(agent-server): read session-socket messages while a step runs #6709's behavior (a message sent during a step is saved even if the client leaves) is unchanged.test_an_error_for_a_frame_sent_while_a_step_runs_comes_after_sync.Issue Number
Fixes #6745
How to Test
1 failed, 16 passed; theerrorframe was already on the wire while subscribe was still blocked (assert [{'type': 'error', ...}] == []).17 passed; the full socket set above:99 passed. The fix(agent-server): read session-socket messages while a step runs #6709 tests (test_a_message_sent_while_a_step_runs_is_saved_after_the_client_leaves,test_a_frame_that_arrives_with_the_close_is_still_saved) pass.uv run pre-commit run --fileson both changed files: all hooks pass.The map recipe from the issue (
control-agent-server map run --file F07 --fresh) needs a model to keep a step running; the DeepSeek key is out of balance, so it was not run.Video/Screenshots
None; server-side frame ordering change, covered by the unit test above.
Type
Notes
Errors are released after the buffered live events flushed by
go_live; they still followsyncand the replay, which is what the protocol promises. The legacy/sockets/eventsendpoint is untouched.Generated by Claude Code
🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdkpython-node-runtimepython-node-runtimepython-node-runtimegolang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:27f9c06-pythonRun
All tags pushed for this build
About Multi-Architecture Support
27f9c06-python) is a multi-arch manifest supporting both amd64 and arm6427f9c06-python-amd64) are also available if needed