fix(provider-core): a mixed fan-out starts its delegates before native subagents #34746
main fromrefs/pull/34746/head·opened View on GitHubProblem#
A Claude parent asked for parallel reviewers on two providers sends foreground Agent calls and a delegate_task in one message, in that order. The delegate_task child then starts only after the slowest native agent finishes. In #34706 the Codex child started about 2.5 minutes late, 13 ms after the second Agent returned, so the wall time became max(native) + delegate instead of max(all).
The cause is Claude Code's scheduler, not T3. In Claude Code 2.1.322 it splits one message's tool calls into groups: consecutive concurrency-safe calls share a group, any other call gets a group of its own, and the groups run one after another. An MCP tool is concurrency-safe only when it has readOnlyHint: true, or when Claude Code's own host code lists it as able to overlap, which MCP servers and the SDK can't set. delegate_task is correctly not read-only, so it waits behind the Agent calls listed before it.
Change#
One line in the T3 orchestration instructions (packages/provider-core/src/server/orchestrationInstructions.ts), right after the native-vs-delegate_task routing rule:
Fan-out mixing both: call every
delegate_taskfirst,mode:"async", then the native subagents. Adelegate_taskafter a foregroundAgentstarts only once thatAgentfinishes.
- Listed first, an async
delegate_taskruns alone and returns as soon as the child is created. The native agents then run together, with the child already working. mode:"async"matters. Awaitdelegate listed first would hold the native agents back the same way.- The text is provider-neutral, because every provider gets the same orchestration instructions. On Codex it's harmless: starting the delegate first never slows anything down.
Alternatives I ruled out:
- Marking
delegate_taskreadOnlyHint: true. That would make it concurrency-safe, but it's false. Claude Code also uses read-only to decide permissions (isReadOnly), and clients would treat a tool that starts agents as safe. - Claude Code's own overlap list. It's filled by Claude Code's internal host code, not by an MCP server or an SDK option, so T3 can't use it.
agentContextBudget.json grows by the 185 bytes of the new line (claudeSystemAppendBytes 5597 → 5782, codexAdditionalContextBytes 7327 → 7512). The first orchestration section is now 1,693 bytes, well under Codex's 4,000-byte limit per entry.
Scope and approval#
Fixes #34706. The issue names the cause and says nothing in the orchestration instructions warns about it. This is the smallest change T3 controls that removes the delay.
Related but separate: #34379 is about a foreground Agent blocking the parent's own turn. This PR doesn't change that.
Verification#
- New eval case
mixed-fanout-delegate-first(kindbad, Claude harness only) inevals/mcp-tool-use/cases/orchestration.ndjson. It replays the issue's request: Opus, Fable and GPT-6.1 Sol in Codex reviewing one file in parallel. It requires a Soldelegate_taskand at least two nativeAgentcalls, with the firstdelegate_taskbefore the firstAgent. It fails on anydelegate_taskwithmode:"wait"and on a backgroundAgent. Native-only and delegate-only fan-outs are already covered bynative-agents-for-unasked-parallel-audit,codex-same-model-subagents-stay-nativeandcross-provider-delegates-with-options. pnpm mcp-tool-use --case mixed-fanout-delegate-first --dry-runbuilds the case, and the new line appears once in the request's system prompt.vp run check:changed: format, lint, knip, graphql, typecheck (27 packages) and tests pass, includingAgentContextBudget.test.tswith the updated budget andCodexDeveloperInstructions.test.ts.- Not run: the paid eval. I had no Anthropic API key, so I have not shown that the new case fails on main's text and passes on this text, or that the related guards still pass. The commands, from
evals/:pnpm mcp-tool-use --case mixed-fanout-delegate-first --samples 3 --model claude-sonnet-5-5 --out runs/mixed-fanout pnpm mcp-tool-use --case mixed-fanout-delegate-first,native-agents-for-unasked-parallel-audit,opus-review-too-via-delegate,cross-provider-delegates-with-options,subagents-as-you-see-fit-uses-native,sol-native-agent-type-instead-of-delegate --samples 3 --model claude-opus-5-5 --out runs/mixed-fanout-opus - I didn't reproduce the delay end to end in a real T3 thread. The scheduling cause above comes from reading the Claude Code 2.1.322 bundle.
Written by Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — Mixed fan-outs will now be instructed to launch all delegates asynchronously before native subagents. This changes the default orchestration order and concurrency behavior, requiring human confirmation of the intended product behavior.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Umais-Adeed(GitHub profile, opens in a new tab) linked this to fix #34706
Sign in to join this conversation.
Closing: Umais-Adeed already has 3 or more open PRs here, which is the limit for contributors who are not vouched.
Once one of them is merged or closed, open this again. See the open PR limit.