Skip to content

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

Merged
t3dotgg merged 1 commit into
mainfrom
fix/background-wait-schema-and-prompts
Dec 2, 2026
Merged

t3dotgg merged 1 commit into
mainfrom
fix/background-wait-schema-and-prompts

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Dec 2, 2026

Copy link
Copy Markdown
Member

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.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Dec 2, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

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.

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 resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.5 KiB 92.5 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 78.3 KiB 78.3 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 75 75 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 79.2 KiB 79.2 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 75 75 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (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.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

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

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 name Status Explanation
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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

Commits

Reviewing files that changed from the base of the PR and between c37dcd1 and f5d7403.

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.

@t3dotgg
t3dotgg merged commit a3ec5c2 into main Dec 2, 2026
38 checks passed
@t3dotgg
t3dotgg deleted the fix/background-wait-schema-and-prompts branch December 2, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant