Skip to content

fix(sdk): keep streamed deltas out of RemoteConversation.state.events - #5966

Merged
enyst merged 1 commit into
mainfrom
claude/umbrella-bug-fixes-tgz9ai-streaming-state-events
Oct 17, 2026
Merged

enyst merged 1 commit into
mainfrom
claude/umbrella-bug-fixes-tgz9ai-streaming-state-events

Conversation

@enyst

@enyst enyst commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

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=True agent LLM, the events socket carries one transient StreamingDeltaEvent per token chunk. The server never stores them, but RemoteConversation's default socket callback cached every frame, so after a streamed run state.events held one extra entry per delta and no longer matched the server's event log (len(state.events), kind counts).

Summary

  • RemoteEventsList.create_default_callback() skips StreamingDeltaEvent; user callbacks and the visualizer still receive every delta.
  • Unit test: the default callback keeps deltas out of the cached events.
  • Map: drop the # bug marker from F33.conversation-streaming-state and 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 new test_remote_events_list_callback_skips_streaming_deltas fails on main (two extra delta entries) and passes here; uv run pytest tests/sdk/conversation passes (867 passed).
  • uv run pre-commit run --files <changed files>: all hooks pass.
  • Map proof with DeepSeek (stream=True):
    • control-agent-server map run --file F33 --only F33.conversation-streaming-state --fresh --repeat 2 --checkout <main checkout at 6e7a853>: xfail in both attempts.
    • Same command from this branch without --checkout: xpass in both attempts.
    • After dropping the marker: control-agent-server map check ok (34 files, 935 ids, no problems); map run --file F33 --only F33.conversation-streaming-state --fresh: pass.

Video/Screenshots

n/a

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

🤖 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

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:55c3ee3-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-55c3ee3-python \
  ghcr.io/openhands/agent-server:55c3ee3-python

All tags pushed for this build

ghcr.io/openhands/agent-server:55c3ee3-golang-amd64
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-golang-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-golang-amd64
ghcr.io/openhands/agent-server:55c3ee3-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:55c3ee3-golang-arm64
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-golang-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-golang-arm64
ghcr.io/openhands/agent-server:55c3ee3-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:55c3ee3-java-amd64
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-java-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-java-amd64
ghcr.io/openhands/agent-server:55c3ee3-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:55c3ee3-java-arm64
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-java-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-java-arm64
ghcr.io/openhands/agent-server:55c3ee3-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:55c3ee3-python-amd64
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-python-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-python-amd64
ghcr.io/openhands/agent-server:55c3ee3-python-node-runtime-amd64
ghcr.io/openhands/agent-server:55c3ee3-python-arm64
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-python-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-python-arm64
ghcr.io/openhands/agent-server:55c3ee3-python-node-runtime-arm64
ghcr.io/openhands/agent-server:55c3ee3-python-minimal-amd64
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-python-minimal-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-python-minimal-amd64
ghcr.io/openhands/agent-server:55c3ee3-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:55c3ee3-python-minimal-arm64
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-python-minimal-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-python-minimal-arm64
ghcr.io/openhands/agent-server:55c3ee3-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:55c3ee3-python-slim-amd64
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-python-slim-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-python-slim-amd64
ghcr.io/openhands/agent-server:55c3ee3-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:55c3ee3-python-slim-arm64
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-python-slim-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-python-slim-arm64
ghcr.io/openhands/agent-server:55c3ee3-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:55c3ee3-golang
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-golang
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-golang
ghcr.io/openhands/agent-server:55c3ee3-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:55c3ee3-java
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-java
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-java
ghcr.io/openhands/agent-server:55c3ee3-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:55c3ee3-python-minimal
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-python-minimal
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-python-minimal
ghcr.io/openhands/agent-server:55c3ee3-python-node-runtime-minimal
ghcr.io/openhands/agent-server:55c3ee3-python-slim
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-python-slim
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-python-slim
ghcr.io/openhands/agent-server:55c3ee3-python-node-runtime-slim
ghcr.io/openhands/agent-server:55c3ee3-python
ghcr.io/openhands/agent-server:55c3ee3396ea003925867bd746e38920cf334a44-python
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-streaming-state-events-python
ghcr.io/openhands/agent-server:55c3ee3-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., 55c3ee3-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 55c3ee3-python-amd64) are also available if needed

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
@enyst enyst self-assigned this Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/conversation/impl
   remote_conversation.py8038689%112, 187, 214, 227, 229–232, 258, 276–277, 288–291, 298–299, 304–307, 391, 401–403, 409, 493–494, 636–639, 641, 667–671, 676–679, 682, 698, 802, 836, 894–895, 899–900, 914, 980, 986, 1090–1093, 1142–1143, 1167–1168, 1208–1209, 1227, 1237, 1241, 1250–1251, 1290, 1444–1445, 1544–1545, 1549, 1554–1558, 1582, 1587, 1634, 1882–1883, 1891–1892
TOTAL484501306373% 

@enyst
enyst marked this pull request as ready for review October 14, 2026 03:18
@enyst
enyst requested a review from all-hands-bot October 14, 2026 03:20

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 new test_remote_events_list_callback_skips_streaming_deltas).
  • uv run pytest tests/sdk/conversation -> 867 passed.
  • uv run ruff check and ruff format --check on 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

@enyst
enyst merged commit 8d2c996 into main Oct 17, 2026
57 checks passed
@enyst
enyst deleted the claude/umbrella-bug-fixes-tgz9ai-streaming-state-events branch October 17, 2026 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: RemoteConversation.state.events keeps every StreamingDeltaEvent frame with a streaming LLM

3 participants