fix: reuse sub-agent broadcast bridges - #2006
Conversation
🦋 Changeset detectedLatest commit: 0c149fa 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 |
|
Local workerd + streaming-tail reproduction found an important constraint: retained reverse-RPC bridge calls avoid |
|
Closing this approach after validating it with a local workerd + streaming-tail reproduction. Retaining the reverse-RPC bridge removes DO subrequests, but keeps the originating invocation open until disposal and could interfere with hibernation/recovery. We need a broader, lifecycle-bounded design. |
A streamed sub-agent chat produced 1,019
_cf_broadcastToSubAgentand 882setNameJSRPC calls because broadcasts that outlived their WebSocket handler resolved the root Agent for every chunk.Retain the connection bridge with
dup()and reuse that capability after the handler returns. This keeps broadcasts on the existing root/facet RPC session instead of creating root DO subrequests, while preserving root resolution as the cold-wake fallback. Retained bridges are replaced on reconnect and disposed on replacement or close.