Skip to content

Fix sub-agent WebSocket forwarding#1443

Merged
threepointone merged 8 commits intomainfrom
fix-subagent-websocket-rpc-resume
May 1, 2026
Merged

Fix sub-agent WebSocket forwarding#1443
threepointone merged 8 commits intomainfrom
fix-subagent-websocket-rpc-resume

Conversation

@threepointone
Copy link
Copy Markdown
Contributor

Summary

  • Keep sub-agent browser WebSockets owned by the parent Agent and forward child connect/message/close events over RPC.
  • Preserve sub-agent real-time chat behavior while avoiding native WebSocket I/O ownership errors in deployed Workers.
  • Fix resumed chat streams rendering replayed text as a second assistant text block.

Test plan

  • npm run build (packages/agents)
  • npm run test:workers -- spike-sub-agent-routing.test.ts (packages/agents)
  • npm run test:react -- use-agent-chat.test.tsx (packages/ai-chat)
  • npm run build (packages/ai-chat)
  • Deployed and browser-verified multi-ai-chat long story resume/thread switching

Made with Cursor

Keep sub-agent browser WebSockets owned by the parent Agent and resume chat streams without duplicating assistant text blocks.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 1, 2026

🦋 Changeset detected

Latest commit: f61c535

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@cloudflare/ai-chat Patch
@cloudflare/think Patch
agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

threepointone and others added 2 commits May 1, 2026 16:39
Persist child virtual connection metadata, preserve child connection flags across RPC forwarding, and make replay resume hydration recover safely when the replay targets a different assistant.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cast connection to unknown before asserting { tags: string[] } when assigning the computed tags array. This adjusts the TypeScript type assertion to satisfy stricter type-checking (avoiding a direct incompatible cast) while preserving runtime behavior of setting connection.tags to [connection.id, ...childTags]. No functional change intended.
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 1, 2026

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@1443

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@1443

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@1443

hono-agents

npm i https://pkg.pr.new/hono-agents@1443

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@1443

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@1443

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@1443

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@1443

commit: f61c535

threepointone and others added 5 commits May 1, 2026 17:45
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Keep child WebSocket connection behavior closer to top-level agents and make completed stream replay stricter after late ACKs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Ensure the mutable agent fields reflect the identity frame before resolving ready, closing a small React render race.

Co-authored-by: Cursor <cursoragent@cursor.com>
@threepointone threepointone merged commit e7d225b into main May 1, 2026
2 checks passed
@threepointone threepointone deleted the fix-subagent-websocket-rpc-resume branch May 1, 2026 22:29
@github-actions github-actions Bot mentioned this pull request May 1, 2026
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.

1 participant