fix(mcp): agents call t3_background_wait with taskIds on the first try #47243
main fromrefs/pull/47243/head·merged by t3dotgg(GitHub profile, opens in a new tab) View on GitHubClaude 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_waitwithanthropic/alwaysLoad: trueso Claude Code loads itstaskIdsschema up front. - Name
taskIds: ["<id>"]explicitly in the Claude, Cursor, and OpenCode prompts and tightent3_background_wait's description (shell/Monitor only, excluding subagents/delegates/dev servers), keepingagentContextBudget.jsonbelowmain(6392and63576bytes). - Split
t3_background_waitunmatched-task failures into error codetask_not_found(leavingunsupportedasinvalid_request) and documentt3_thread_wait'stimeoutMsdefault/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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
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
mainmeasurement shown below.Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 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 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅ Codex Live turn messages 1 1 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 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 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅ Claude Live turn messages 1 1 0 (0.0%) 8 ✅ Other scenarios#
All 64 scenario measurements match
main.All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling Codex short turn resumeWebSocket decoded10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅ Codex short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn running, cold openHTTP decoded281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅ Codex long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Codex long turn running, history pageHTTP decoded92.5 KiB 92.5 KiB 0 B (0.0%) 107.4 KiB ✅ Codex long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Codex long turn finished, cold openHTTP decoded381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, socket cold openWebSocket decoded381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅ Codex long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Codex long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Codex long turn finished, work pageHTTP decoded78.3 KiB 78.3 KiB 0 B (0.0%) 200.2 KiB ✅ Codex long turn finished, work pagerows75 75 0 (0.0%) 150 ✅ Codex idle thread resumeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell snapshotHTTP decoded42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅ Codex fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Codex fleet shell subscribeWebSocket decoded65 B 65 B 0 B (0.0%) 200 B ✅ Codex fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Codex fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Codex fleet shell resume checkrows0 0 0 0 ✅ Codex stale shell reloadHTTP decoded42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅ Codex stale shell reloadrows27 27 0 (0.0%) 27 ✅ Codex stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Codex stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Codex stale todo list cold openHTTP decoded72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅ Codex stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Codex stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Codex stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Codex stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Codex stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Codex stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Claude short turn resumeWebSocket decoded10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅ Claude short turn resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn running, cold openHTTP decoded283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅ Claude long turn running, cold openrows75 75 0 (0.0%) 75 ✅ Claude long turn running, history pageHTTP decoded93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅ Claude long turn running, history pagerows75 75 0 (0.0%) 75 ✅ Claude long turn finished, cold openHTTP decoded384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, socket cold openWebSocket decoded384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅ Claude long turn finished, socket cold openWebSocket messages2 2 0 (0.0%) 2 ✅ Claude long turn finished, socket cold openrows151 151 0 (0.0%) 151 ✅ Claude long turn finished, work pageHTTP decoded79.2 KiB 79.2 KiB 0 B (0.0%) 200.2 KiB ✅ Claude long turn finished, work pagerows75 75 0 (0.0%) 150 ✅ Claude idle thread resumeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude idle thread resumeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell snapshotHTTP decoded43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅ Claude fleet shell snapshotrows27 27 0 (0.0%) 27 ✅ Claude fleet shell subscribeWebSocket decoded66 B 66 B 0 B (0.0%) 200 B ✅ Claude fleet shell subscribeWebSocket messages1 1 0 (0.0%) 1 ✅ Claude fleet shell resume checkHTTP decoded18 B 18 B 0 B (0.0%) 100 B ✅ Claude fleet shell resume checkrows0 0 0 0 ✅ Claude stale shell reloadHTTP decoded43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅ Claude stale shell reloadrows27 27 0 (0.0%) 27 ✅ Claude stale shell resumeWebSocket decoded140 B 140 B 0 B (0.0%) 400 B ✅ Claude stale shell resumeWebSocket messages2 2 0 (0.0%) 2 ✅ Claude stale todo list cold openHTTP decoded73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅ Claude stale todo list cold openrows75 75 0 (0.0%) 75 ✅ Claude stale todo list cold opennodes2 2 0 (0.0%) 4 ✅ Claude stale todo list cold opensubagents2 2 0 (0.0%) 4 ✅ Claude stale todo list cold openplans1 1 0 (0.0%) 2 ✅ Claude stale todo list cold openproviderTurns1 1 0 (0.0%) 2 ✅ Claude stale todo list cold opencheckpoints1 1 0 (0.0%) 2 ✅ Baseline:
902d26d· PR result:f5d7403· 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.
Walkthrough
-
The pull request updates
t3_background_waiterror mapping, tool metadata, and agent instructions. The instructions specifytaskIdsarrays 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.tsUnmatched 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.tsThe 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.ndjsonClaude, Cursor, and OpenCode instructions use taskIdsarrays. 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
taskIdsargument 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 - pingdotgg/t3code#31889 — The updated Claude instruction uses the required
Merge Risk:
Minimal · up tof5d74-
This change makes agents more likely to call the background wait tool with the correct
taskIdsarray 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:
4-
Check name Status Explanation Title check 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 … Description check 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-… 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: 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-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: fix/background-wait-schema-and-prompts
- File: .coderabbit.config.ts
- Commit: f5d7403
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
c98d1c10-7a4f-4f99-b93c-581b88af97ed
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.tsapps/server/src/mcp/toolkits/orchestrator/handlers.tsapps/server/src/mcp/toolkits/orchestrator/tools.tsapps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.tsapps/server/src/provider/AgentContextBudget.test.tsapps/server/src/provider/agentContextBudget.jsonevals/mcp-tool-use/cases/orchestration.ndjsonpackages/contracts/src/orchestratorMcp.tspackages/provider-cursor/src/server/adapter.tspackages/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.
-
-
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 — 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).