Fix sub-agent workflow origins#1430
Draft
threepointone wants to merge 1 commit intomainfrom
Draft
Conversation
Support workflows started from sub-agent facets by preserving the origin path for callbacks, RPC, tracking, and docs. Made-with: Cursor
🦋 Changeset detectedLatest commit: 975480c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This was referenced Apr 30, 2026
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
34 tasks
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.
Summary
Fixes workflows started from sub-agent facets by preserving the exact originating Agent path and routing workflow callbacks/RPC back to that facet instead of assuming a top-level Agent binding.
This addresses the failure mode from #1359 where
runWorkflow()could not detect a binding for sub-agents and gives facet-started workflows the same tracking, callback, and Agent RPC semantics as top-level workflows.What changed
AgentWorkflowOrigininternal payload for workflow starts:{ kind: "agent", binding, name }{ kind: "facet", rootBinding, path }Agent.runWorkflow()to preserve root binding +selfPathfor facet callers._cf_invokeAgentPath()soAgentWorkflow.agent, progress, completion, error, event, and state callbacks land on the originating facet.AgentWorkflow.agentexplicitly RPC-only and throws a clear error for.fetch().onStart()can route callbacks immediately, with rollback if initialization fails.broadcastToClients()await the underlying Agent RPC.onStart()workflow starts, approval/rejection, errors, durable events, state updates, and facet-local tracking.Test plan
npm test -w agents -- src/tests/workflow-sub-agent.test.tsnpm run typechecknpx oxfmt --check packages/agents/src/workflows.ts packages/agents/src/tests/test-workflow.ts packages/agents/src/tests/agents/workflow.ts packages/agents/src/tests/worker.ts packages/agents/src/tests/wrangler.jsonc packages/agents/src/tests/workflow-sub-agent.test.ts docs/workflows.md docs/sub-agents.md docs/long-running-agents.md docs/human-in-the-loop.mdNote: the targeted workflow suite logs expected Workflows runtime exceptions for intentionally thrown/rejected workflow cases, while the suite itself passes.
Made with Cursor