Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): running delegates tell agents to end the turn #24887

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/24887/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Problem

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-task next now 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: the task_status description 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 with task_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. 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).
    2. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB−7 B (−0.1%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB−7 B (−0.6%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB−24 B (−0.5%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB−24 B (−2.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB−41 B (−0.2%)29.3 KiB✅
      ClaudeLive turn messages21−1 (−50.0%)8✅

      Baseline: 3d00499 · PR result: 6c9ea4d · Source CI: success

      Scenario 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.

    3. Review in Change Stack →

      No actionable comments were generated in the recent review.

      Recent review info
      Run configuration
      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.ts
      • packages/contracts/src/orchestratorMcp.ts
      • packages/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

      Layer / File(s)Summary
      Running-task polling guidance
      packages/contracts/src/orchestratorMcp.ts, apps/server/src/mcp/toolkits/orchestrator/tools.ts
      The 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.ts
      The instruction says to use task_cancel when replacing a delegate run or when it is no longer needed. The prohibition on using t3_thread_interrupt for a childThreadId remains.
      Priority: Low

      Estimated 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: bugfix

      Suggested reviewers: maria-rcks, macroscopeapp

      Merge Risk: Minimal · up to 6c9ea

      No actionable merge-blocking risk was identified.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck 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
      Comment `@coderabbitai help` to get the list of available commands.

Sign in to join this conversation.