Repository navigation
fix(agents): route WebSockets through sub-agents nested past one level - #2400
Merged
threepointone merged 1 commit intoSep 28, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 3ffc90a The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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
added this pull request to stack #2407
September 28, 2026 14:47
Contributor
|
✅ agents import sizes: no significant changes ( |
threepointone
marked this pull request as ready for review
September 28, 2026 14:49
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
threepointone
force-pushed
the
fix/nested-subagent-websockets
branch
from
September 28, 2026 15:46
9ba029f to
e3556a3
Compare
The outer-URL header meant for the root-owned socket was forwarded to every child. A second-level child copied it into its connection flag and resolved its connection from the top of the chain, routing back into the first level until the facet depth limit threw. Co-authored-by: Cursor <cursoragent@cursor.com>
threepointone
force-pushed
the
fix/nested-subagent-websockets
branch
from
September 28, 2026 16:54
e3556a3 to
3ffc90a
Compare
threepointone
added a commit
to AntoniTok/agents
that referenced
this pull request
Sep 29, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
Merged
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.
Problem
I found this while testing #2118; there was no issue for it. WebSockets to a sub-agent three or more levels deep failed with "Facet nesting depth limit exceeded".
The root forwards the
x-cf-agents-subagent-urlheader, which is meant only for the root-owned socket, to every child inmeta.requestHeaders. A second-level child'sonConnectwrapper copied it into its outer-URL flag and resolved its own connection from the top of the chain. The third hop then routed back into the second level, recursively, until the depth limit threw.Fix
#resolveConnectiondrops that header from the headers it forwards to the child.Tests
sub-agent-routing.test.tsconnects two clients through three and four levels of sub-agents. Both see the leaf's identity, a state frame from one is broadcast to the other, and neither sees an error frame. The test fails without the fix.