fix(server): running delegates tell agents to end the turn #24887
main fromrefs/pull/24887/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubProblem#
In the MCP tool-use eval (#24635), GPT-6.1 Sol polled delegates that were still running. The old running-task next text let it wait when it "needed the result now". Sol also left a stale review delegate running after it started a new one.
Change#
Three one-line text changes:
packages/contracts/src/orchestratorMcp.ts: the running-tasknextnow says "Completion wakes this thread, so end your turn. Do not wait on it or poll it."apps/server/src/mcp/toolkits/orchestrator/tools.ts: thetask_statusdescription says not to call it on a running task before its completion wakes you.packages/provider-core/src/server/orchestrationInstructions.ts: stop a delegate run you replace or no longer need withtask_cancel.
Scope and approval#
Maintainer work (Theo). Text only, no behavior change. It follows the instruction cuts in #24850.
Verification#
Full MCP eval runs with this text (a case fails when half or more of its samples fail):
- Claude Opus 5.5: 1 failing case of 85, 95% of samples pass. The failing case is
child-pr-not-linked: the child runs out of its 8 steps. - GPT-6.1 Sol: 0 failing cases of 83. The 3 Claude-only cases do not run.
- GPT-6 Astra, on the 7 delegate cases this text touches: 14 of 14 samples pass.
node scripts/check-changed.ts passes. vp test run src/orchestration-v2/testkit src/mcp in apps/server passes (413 tests).
Changes made with Claude Opus 5.5 in Claude Code (T3 Code).
🤖 Generated with Claude Code
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB −7 B (−0.1%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB −7 B (−0.6%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅ Codex Live turn messages 2 2 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB −24 B (−0.5%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB −24 B (−2.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB −41 B (−0.2%) 29.3 KiB ✅ Claude Live turn messages 2 1 −1 (−50.0%) 8 ✅ Baseline:
3d00499· PR result:6c9ea4d· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
No actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: copy/delegate-wake-copy
- File: .coderabbit.config.ts
- Commit: 6c9ea4d
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
ced4a3e4-6b13-42de-b267-b219bba07196
Commits-
Reviewing files that changed from the base of the PR and between 3d004999362848ae33b6f40e4bbd33b9d5c0ea59 and 6c9ea4df3d1ac1ed2cce130250511d280f86a014.
Files selected for processing: 3-
apps/server/src/mcp/toolkits/orchestrator/tools.tspackages/contracts/src/orchestratorMcp.tspackages/provider-core/src/server/orchestrationInstructions.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
-
Walkthrough
-
The changes update orchestration guidance for running-task polling and delegate cancellation. Callers are instructed to end their turn when completion will wake the thread, and to cancel delegate runs only when replacing them or when they are no longer needed.
Changes: Orchestration guidance
Priority:Layer / File(s) Summary Running-task polling guidance
packages/contracts/src/orchestratorMcp.ts,apps/server/src/mcp/toolkits/orchestrator/tools.tsThe running-task message says completion wakes the thread and directs callers not to wait or poll. The task-status description says not to query a running task before completion wakes the caller. Delegate cancellation guidance
packages/provider-core/src/server/orchestrationInstructions.tsThe instruction says to use task_cancelwhen replacing a delegate run or when it is no longer needed. The prohibition on usingt3_thread_interruptfor achildThreadIdremains. LowEstimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix
Possibly related PRs
- pingdotgg/t3code#24782: It adds the running-task message that this PR updates, alongside matching task-status guidance.
- pingdotgg/t3code#24850: It introduced the orchestration guidance that this PR refines.
- pingdotgg/t3code#21676: It changes cancellation finalization for delegated runs, related to this PR’s delegate-cancellation instruction.
Suggested labels:
bugfixSuggested reviewers:
maria-rcks,macroscopeapp
Merge Risk:
Minimal · up to6c9ea-
No actionable merge-blocking risk was identified.
Pre-merge checks:
4-
Check name Status Explanation Title check The title clearly identifies the main change: running delegates now tell agents to end the turn. It is concise and related to the instruction updates. Description check The description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the affected instructions, approval context, focused evaluation results, and test resu… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Description check
-
Explanation
The description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the affected instructions, approval context, focused evaluation results, and test results.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Approvability#
Verdict: Needs Human Approval
Macroscope's review found this PR requires human approval — This small change updates the agent-facing running-delegate protocol and the default orchestration instructions used for MCP-enabled agents. Because it changes default product behavior, human review is required under the configured approval criteria.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).