Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mcp): agents call t3_background_wait with taskIds on the first try #47243

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

Claude Code deferred t3_background_wait behind ToolSearch, while the system prompts asked agents to pass "its task ID" / "its shell ID or pid". Agents routinely called the unloaded tool with singular { taskId } / { shellId } / { pid } (hitting InvalidParams), or passed subagent/delegate IDs and got an invalid_request indistinguishable from unsupported providers.

  • Mark t3_background_wait with anthropic/alwaysLoad: true so Claude Code loads its taskIds schema up front.
  • Name taskIds: ["<id>"] explicitly in the Claude, Cursor, and OpenCode prompts and tighten t3_background_wait's description (shell/Monitor only, excluding subagents/delegates/dev servers), keeping agentContextBudget.json below main (6392 and 63576 bytes).
  • Split t3_background_wait unmatched-task failures into error code task_not_found (leaving unsupported as invalid_request) and document t3_thread_wait's timeoutMs default/max (Default 30000, max 45000.).

Proof: vp run check:changed passes (612 tests across 6 files, including AgentContextBudget.test.ts and core.test.ts); evals/mcp-tool-use/run.test.ts (530 tests) and --case background-wait-uses-task-ids-array --dry-run confirm t3_background_wait loads up front with its taskIds schema (live Claude eval samples were not run here because ANTHROPIC_API_KEY is unavailable).

Reviewed with sol-loop: 2 passes with GPT-6.2 Sol. Sol verdict: approved.

Created with Gemini 4 Neon in Antigravity.

    1. tanstack-source added labelsbug

    2. Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — The PR clarifies taskIds usage and changes Claude’s background-wait tool from deferred discovery to automatic loading. That default-loading change requires human review, although the underlying background-wait operation remains scoped to the caller’s thread.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Other scenarios

      All 64 scenario measurements match main.

      All 64 scenario measurements
      ProviderScenarioMetricMain baselineThis PRImpactPR ceiling
      Codexshort turn resumeWebSocket decoded10.5 KiB10.5 KiB0 B (0.0%)12.7 KiB✅
      Codexshort turn resumeWebSocket messages220 (0.0%)2✅
      Codexlong turn running, cold openHTTP decoded281.7 KiB281.7 KiB0 B (0.0%)302.7 KiB✅
      Codexlong turn running, cold openrows75750 (0.0%)75✅
      Codexlong turn running, history pageHTTP decoded92.5 KiB92.5 KiB0 B (0.0%)107.4 KiB✅
      Codexlong turn running, history pagerows75750 (0.0%)75✅
      Codexlong turn finished, cold openHTTP decoded381.5 KiB381.5 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, socket cold openWebSocket decoded381.6 KiB381.6 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Codexlong turn finished, socket cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, work pageHTTP decoded78.3 KiB78.3 KiB0 B (0.0%)200.2 KiB✅
      Codexlong turn finished, work pagerows75750 (0.0%)150✅
      Codexidle thread resumeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexidle thread resumeWebSocket messages110 (0.0%)1✅
      Codexfleet shell snapshotHTTP decoded42.4 KiB42.4 KiB0 B (0.0%)53.7 KiB✅
      Codexfleet shell snapshotrows27270 (0.0%)27✅
      Codexfleet shell subscribeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexfleet shell subscribeWebSocket messages110 (0.0%)1✅
      Codexfleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Codexfleet shell resume checkrows0000✅
      Codexstale shell reloadHTTP decoded42.4 KiB42.4 KiB0 B (0.0%)53.7 KiB✅
      Codexstale shell reloadrows27270 (0.0%)27✅
      Codexstale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Codexstale shell resumeWebSocket messages220 (0.0%)2✅
      Codexstale todo list cold openHTTP decoded72.4 KiB72.4 KiB0 B (0.0%)83.0 KiB✅
      Codexstale todo list cold openrows75750 (0.0%)75✅
      Codexstale todo list cold opennodes220 (0.0%)4✅
      Codexstale todo list cold opensubagents220 (0.0%)4✅
      Codexstale todo list cold openplans110 (0.0%)2✅
      Codexstale todo list cold openproviderTurns110 (0.0%)2✅
      Codexstale todo list cold opencheckpoints110 (0.0%)2✅
      Claudeshort turn resumeWebSocket decoded10.6 KiB10.6 KiB0 B (0.0%)12.7 KiB✅
      Claudeshort turn resumeWebSocket messages220 (0.0%)2✅
      Claudelong turn running, cold openHTTP decoded283.3 KiB283.3 KiB0 B (0.0%)302.7 KiB✅
      Claudelong turn running, cold openrows75750 (0.0%)75✅
      Claudelong turn running, history pageHTTP decoded93.4 KiB93.4 KiB0 B (0.0%)107.4 KiB✅
      Claudelong turn running, history pagerows75750 (0.0%)75✅
      Claudelong turn finished, cold openHTTP decoded384.2 KiB384.2 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, socket cold openWebSocket decoded384.3 KiB384.3 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Claudelong turn finished, socket cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, work pageHTTP decoded79.2 KiB79.2 KiB0 B (0.0%)200.2 KiB✅
      Claudelong turn finished, work pagerows75750 (0.0%)150✅
      Claudeidle thread resumeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudeidle thread resumeWebSocket messages110 (0.0%)1✅
      Claudefleet shell snapshotHTTP decoded43.0 KiB43.0 KiB0 B (0.0%)53.7 KiB✅
      Claudefleet shell snapshotrows27270 (0.0%)27✅
      Claudefleet shell subscribeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudefleet shell subscribeWebSocket messages110 (0.0%)1✅
      Claudefleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Claudefleet shell resume checkrows0000✅
      Claudestale shell reloadHTTP decoded43.0 KiB43.0 KiB0 B (0.0%)53.7 KiB✅
      Claudestale shell reloadrows27270 (0.0%)27✅
      Claudestale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Claudestale shell resumeWebSocket messages220 (0.0%)2✅
      Claudestale todo list cold openHTTP decoded73.4 KiB73.4 KiB0 B (0.0%)83.0 KiB✅
      Claudestale todo list cold openrows75750 (0.0%)75✅
      Claudestale todo list cold opennodes220 (0.0%)4✅
      Claudestale todo list cold opensubagents220 (0.0%)4✅
      Claudestale todo list cold openplans110 (0.0%)2✅
      Claudestale todo list cold openproviderTurns110 (0.0%)2✅
      Claudestale todo list cold opencheckpoints110 (0.0%)2✅

      Baseline: 902d26d · PR result: f5d7403 · 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.

    4. Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The pull request updates t3_background_wait error mapping, tool metadata, and agent instructions. The instructions specify taskIds arrays for background shell and Monitor work. Tests cover matched and unmatched task IDs and the tool’s always-load metadata.

      Changes: Background wait

      Layer / File(s)Summary
      Wait result handling
      apps/server/src/mcp/toolkits/orchestrator/handlers.ts, apps/server/src/mcp/toolkits/core.test.ts
      Unmatched tasks now map to task_not_found. Tests cover matched and unmatched task IDs.
      Tool descriptions and metadata
      apps/server/src/mcp/toolkits/orchestrator/tools.ts, packages/contracts/src/orchestratorMcp.ts
      The tool descriptions clarify background-wait task scope and thread-wait behavior. The background-wait tool gains Anthropic always-load metadata. The timeout description states a default of 30,000 ms and a maximum of 45,000 ms.
      Agent guidance and validation
      apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, packages/provider-cursor/src/server/adapter.ts, packages/provider-opencode/src/server/v2/adapter.ts, apps/server/src/provider/AgentContextBudget.test.ts, apps/server/src/provider/agentContextBudget.json, evals/mcp-tool-use/cases/orchestration.ndjson
      Claude, Cursor, and OpenCode instructions use taskIds arrays. The evaluation checks this argument shape, and the context-budget test and values account for the always-loaded tool.

      Estimated code review effort: 2 (Simple) | ~12 minutes

      Change: Bug fix

      Possibly related issues

      • pingdotgg/t3code#31889 — The updated Claude instruction uses the required taskIds argument shape described in the issue.
      • pingdotgg/t3code#24956 — The instructions now exclude subagents and delegates, but the changes do not add rejection of tasks owned by subagents.

      Suggested reviewers: juliusmarminge, yash-singh1

      Merge Risk: Minimal · up to f5d74

      This change makes agents more likely to call the background wait tool with the correct taskIds array and reports unmatched tasks with a clearer error code. No actionable merge-blocking risk was identified; live model evals were not run.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title names the main change: agents should call t3_background_wait with a taskIds array on the first try. The changeset updates the Claude, Cursor, and OpenCode prompts to show taskIds, marks the …
      Description checkPassedThe description follows the template's main sections: Problem, Change, Scope (via the stated bug and the linked context), and Verification. The Problem section explains the deferred-tool and singular-…
      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: Title check

      Explanation

      The title names the main change: agents should call t3_background_wait with a taskIds array on the first try. The changeset updates the Claude, Cursor, and OpenCode prompts to show taskIds, marks the tool alwaysLoad, and refines the tool description. The title is specific and follows a conventional commit format.

      Full details: Description check

      Explanation

      The description follows the template's main sections: Problem, Change, Scope (via the stated bug and the linked context), and Verification. The Problem section explains the deferred-tool and singular-ID failures. The Change section lists the fixes. The Verification section gives specific test counts and results and states what was not checked (live Claude eval). Scope is only partly covered: the PR does not link an issue or state why no issue is needed, and it adds a documentation change (timeoutMs) and an error-code split that go beyond the stated bug. The author should link the issue or explain why none is needed, and should separate the timeoutMs documentation change into its own PR or justify it under the same problem. Also, the Verification section should note that agentContextBudget.json was updated to the new byte counts and why.

      Finishing Touches

      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between c37dcd19b1d56f5be9dc8e9017ce38780a552f8d and f5d7403ef2975f1334d5ef199f69d417d28e004e.

      Files selected for processing: 10

      • apps/server/src/mcp/toolkits/core.test.ts
      • apps/server/src/mcp/toolkits/orchestrator/handlers.ts
      • apps/server/src/mcp/toolkits/orchestrator/tools.ts
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
      • apps/server/src/provider/AgentContextBudget.test.ts
      • apps/server/src/provider/agentContextBudget.json
      • evals/mcp-tool-use/cases/orchestration.ndjson
      • packages/contracts/src/orchestratorMcp.ts
      • packages/provider-cursor/src/server/adapter.ts
      • packages/provider-opencode/src/server/v2/adapter.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Sign in to join this conversation.