Repository navigation
fix(sdk): keep streamed deltas out of RemoteConversation.state.events - #5966
Conversation
With a stream=True LLM the events socket carries one transient StreamingDeltaEvent per token chunk. The server never stores them, but RemoteConversation's default callback cached every frame, so state.events stopped matching the server's event log. The default callback now skips them; other callbacks still receive every delta. Drops the known-bug marker from F33.conversation-streaming-state. Fixes #5963 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014MKndVj7XWvRQmvW9w2bDg
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Coverage Report •
|
||||||||||||||||||||
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Reviewed head 55c3ee3 (base main). The change makes RemoteEventsList.create_default_callback() drop StreamingDeltaEvent before caching, which is the correct minimal fix for #5963: the server publishes deltas directly to pub/sub and never persists them (event_service._publish_stream_delta; see the StreamingDeltaEvent docstring), so the client cache should match the stored event log. Deltas still reach user callbacks and the visualizer because compose_callbacks invokes every callback with the raw event and only the default callback returns early. reconcile()/_add_event_unsafe() fetch from the server, which never stores deltas, so they remain clean too.
Verification performed in the workspace:
uv run pytest tests/sdk/conversation/remote/test_remote_events_list.py-> 11 passed (including the newtest_remote_events_list_callback_skips_streaming_deltas).uv run pytest tests/sdk/conversation-> 867 passed.uv run ruff checkandruff format --checkon the changed files -> clean.- Current-head CI: no failing or neutral non-skipped check runs; the REST-API breakage check and coverage report both passed.
All four acceptance criteria in #5963 (currently bug, priority:low, ready-for-dev) are addressed, and the F33 map bullet consistently drops its # bug marker. The PR also supplies before/after runtime evidence for the streaming path (xfail on main, xpass on the branch, pass after marker removal), which satisfies the live-evidence expectation for this integration-level fix.
Non-blocking cross-layer note: the PR states "The TypeScript client keeps no remote event cache, so it needs no change." That is not accurate. clients/typescript/src/conversation/remote-conversation.ts builds a combinedCallback that calls this.state.events.addEvent(event) for every WebSocket frame, and clients/typescript/src/events/remote-events-list.ts keeps a cachedEvents list that getEvents() merges into its result. The TS client subscribes to the same /sockets/events endpoint, whose _WebSocketSubscriber sets receives_streaming_deltas = True, so it receives the same delta frames. The parity bug therefore likely persists in the TypeScript mirror and is worth a follow-up issue. This does not block the Python fix, which is correctly scoped to #5963.
✅ APPROVED
HUMAN:
This PR proposes a fix for a bug uncovered during the first full agentic run of
verify-agent-server.AGENT:
I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.
Requested by Engel · project thread
Why
With a
stream=Trueagent LLM, the events socket carries one transientStreamingDeltaEventper token chunk. The server never stores them, butRemoteConversation's default socket callback cached every frame, so after a streamed runstate.eventsheld one extra entry per delta and no longer matched the server's event log (len(state.events), kind counts).Summary
RemoteEventsList.create_default_callback()skipsStreamingDeltaEvent; user callbacks and the visualizer still receive every delta.# bugmarker fromF33.conversation-streaming-stateand rewrite its prose and the Gotchas line as the expected behaviour.Issue Number
Fixes #5963
How to Test
uv run pytest tests/sdk/conversation/remote/test_remote_events_list.py: the newtest_remote_events_list_callback_skips_streaming_deltasfails on main (two extra delta entries) and passes here;uv run pytest tests/sdk/conversationpasses (867 passed).uv run pre-commit run --files <changed files>: all hooks pass.stream=True):control-agent-server map run --file F33 --only F33.conversation-streaming-state --fresh --repeat 2 --checkout <main checkout at 6e7a853>:xfailin both attempts.--checkout:xpassin both attempts.control-agent-server map checkok (34 files, 935 ids, no problems);map run --file F33 --only F33.conversation-streaming-state --fresh:pass.Video/Screenshots
n/a
Type
Notes
RemoteConversation: fix(sdk): pass events missed during a WebSocket reconnect to RemoteConversation callbacks #5950 (wraps the socket callback in_initialize_connectionto track delivered ids on reconnect) and a parallel fix routing streamed deltas totoken_callbacksfor remote workspaces; both may also touch the F33 Gotchas line edited here.🤖 Generated with Claude Code
https://claude.ai/code/session_014MKndVj7XWvRQmvW9w2bDg
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:55c3ee3-pythonRun
All tags pushed for this build
About Multi-Architecture Support
55c3ee3-python) is a multi-arch manifest supporting both amd64 and arm6455c3ee3-python-amd64) are also available if needed