Skip to content

Fix delayed sub-agent WebSocket operations - #2090

Merged
ben-reitz merged 18 commits into
mainfrom
fix-2055-subagent-continuation-resume
Aug 26, 2026
Merged

Fix delayed sub-agent WebSocket operations#2090
ben-reitz merged 18 commits into
mainfrom
fix-2055-subagent-continuation-resume

Conversation

@ben-reitz

@ben-reitz ben-reitz commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Stacked on #2027. Fixes #2055.

Why

A sub-agent's virtual WebSocket Connection lives longer than the Workers RPC bridge used to forward one browser frame. Delayed work could therefore call connection.send() through a bridge that had already been disposed.

Think exposed this when STREAM_PENDING arrived but the later STREAM_RESUMING send was dropped, leaving the client waiting for its 60-second timeout. #2027 fixes which bridge an in-flight callable reply uses; this PR handles connection activity after that frame has finished.

What changed

  • Track the live bridge for each forwarded invocation and invalidate it when the invocation ends.
  • Route delayed send, setState, and close calls through the durable root Agent, in call order, with failures reported.
  • Preserve the upstream broadcast capability for active nested frames and use the root when a relay has no live bridge.
  • Add real WebSocket regressions for delayed delivery, state, close, ordering, failure recovery, and fresh-context broadcasts.

Validation

  • pnpm run check
  • Agents tests: 2,488 passed
  • Reporter's Think reproduction passes in direct and sub-agent modes with STREAM_PENDING → STREAM_RESUMING → done

Open in Devin Review

@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1760fcf

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

This PR includes changesets to release 2 packages
Name Type
agents Patch
@cloudflare/agent-think 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

devin-ai-integration[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Aug 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/cloudflare/agents@2090

@cloudflare/ai-chat

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

@cloudflare/channels

npm i https://pkg.pr.new/cloudflare/agents/@cloudflare/channels@2090

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: 1760fcf

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

Base automatically changed from fix-1991-facet-rpc-replies to main August 24, 2026 08:38
@ben-reitz
ben-reitz merged commit 2f957bc into main Aug 26, 2026
15 checks passed
@ben-reitz
ben-reitz deleted the fix-2055-subagent-continuation-resume branch August 26, 2026 10:09
@github-actions github-actions Bot mentioned this pull request Aug 25, 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.

Client tool continuation stays pending for 60 seconds after completion

2 participants