[Bug]: agents can't recover from t3_background_wait refusals #37006
Before submitting#
- I searched existing issues and did not find a duplicate. Related: #31914 (the
taskIdskey in the guidance), #33658 (registration timeouts).
Area#
apps/server
Summary#
t3_background_wait refuses calls in ways the calling agent can't repair: it is listed to providers that can never serve it, a task that finished before registration looks like an invented ID, and a miss doesn't say which IDs are running. The refusals themselves are right (nothing is registered wrongly); the agent just gets nothing to retry with. We have been running the fix below in a fork and are happy to send a PR.
What happens#
- Same-response registration. Claude often sends
Bash run_in_backgroundandt3_background_waitin one assistant message. The task ID exists only in the Bash result, so the wait carries an ID the model made up. It is refused as unmatched, and the model usually retries a few seconds later with the real ID. The instruction text ("callt3_background_waitwith its task ID before you end your turn") does not say when the ID exists. One model also sent{"taskId": "…"}(singular). - Finished before registration. A short command can end, with its
task_notificationhandled and the roster entry gone, before the model's next response registers it. That is refused exactly like an invented ID. - Unsupported providers.
BackgroundWaitToolhas noMcpSchema.EnabledWhen, so Codex, Pi, ACP agents and others list a tool that always fails with "This provider cannot mark background work as awaited." The handler maps that toinvalid_request, so it reads as the agent's mistake.
Where#
apps/server/src/mcp/toolkits/orchestrator/tools.ts:BackgroundWaitTool(description, noEnabledWhen).apps/server/src/orchestration-v2/ThreadManagementService.ts:awaitBackgroundTasks;ThreadManagementBackgroundWaitErrorunmatchedmessage.packages/provider-core/src/server/ProviderAdapter.ts:awaitBackgroundTasksreturns only{ matched }.apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts: matches the pending roster only;CLAUDE_BACKGROUND_WAIT_INSTRUCTIONS.packages/provider-opencode/src/server/v2/adapter.ts: matches running shells only; the shell instruction text.
Proposed fix#
- List the tool only where it works. Add an adapter-level capability (we used
backgroundWait?: Effect.Effect<boolean>on theProviderAdapterV2service, so the composite OpenCode driver can answer for the protocol version a session would use). Stamp it on the MCP thread credential when it is minted, next tosubagent, and annotateBackgroundWaitToolwith anEnabledWhenthat reads it. Keep theunsupportedbranch as a defence. - Report finished tasks as settled. Each adapter remembers task IDs that finished on a thread
(bounded; we keep 64 per session).
awaitBackgroundTasksreturns{ matched, settled?, running? }. A registration whose IDs are only settled succeeds withsettled: [...]("already finished: read their output now") and holds nothing. A reused ID that is running again counts as running. - Name the running tasks on a miss. When nothing matched and nothing settled, return up to 5
running, not-yet-awaited tasks with a bounded description (the command or task description). The
unmatched message appends: "Running and not yet awaited here:
<id>(). Call again with one of these IDs." The agent started those commands itself, so nothing new is disclosed. - Say when the ID exists. Tool description and both instruction texts: "In a later response
than the start, pass the ID its result shows:
taskIds: [id]." (#31914 already fixes thetaskIdskey wording; this adds the "later response" part.)
Not proposed: waiting server-side for an unknown ID to appear (an invented ID never appears),
treating every unmatched ID as success, or accepting taskId as an alias.
Tests we added#
- An invented ID while two tasks run returns
matched: []and both asrunning; an awaited task is no longer listed; after itstask_notification, registering it returnssettled: [id](Claude adapter, driven by SDK frames). - The OpenCode shell tests that registered a finished shell now expect
settled: [shellId]. - The thread service passes
settledthrough as success and appends the running list to the unmatched error. EnabledWhenlists the tool for a credential with the capability and hides it otherwise.
tanstack-source added labelsbug
Adding 24h production telemetry from T3 Code
0.1.12-nightly.20261122.5111(2,738t3_background_waitcalls across 6 orchestrator trees):- 300 calls (11.0%) failed with
OrchestratorMcpFailure invalid_request: None of these IDs is running background work on this threadacross 173 threads. - Cross-referencing each Claude Code transcript's Bash launch and
<task-notification>timestamps:- 223 / 300 waited on a Bash task that had already completed (median task runtime 2.2s, p90 20s;
t3_background_waitarrived a median 1.6s after completion, p90 6.1s). Treating already-finished task IDs on the thread as a satisfied no-op ({"matched": [], "finished": [...]}) instead ofinvalid_requestwould eliminate 74% of these failures. - 96 / 300 (slight overlap with above on multi-ID calls) were emitted in the same assistant response as the Bash launch using a hallucinated
b########ID because the injected prompt does not explicitly state "call after the launch returns its ID, never in the same response".
- 223 / 300 waited on a Bash task that had already completed (median task runtime 2.2s, p90 20s;
- 300 calls (11.0%) failed with
#39421, now on main: Antigravity now accepts t3_background_wait while its own background command is running, removing the unsupported-provider refusal for that ACP provider.
Not done: The issue still asks for filtering unsupported providers, recognizing finished tasks, naming running tasks on a miss, and clarifying when task IDs become available.
Closing; open a new issue if what is left still matters to you.
juliusmarminge closed this
#38348, now on main: The merge hides t3_background_wait from providers without background-wait support, addressing the unsupported-provider refusals reported in this issue.
Not done: The issue still asks for recovery from incorrect or already-finished task IDs, including running-task suggestions and guidance to register only after receiving the launch result; those changes are absent.
Closing; open a new issue if what is left still matters to you.
Sign in to join this conversation.
Note
🤖 GPT-6 Astra responding on behalf of JB357345688
A related observation for proposal 4, concerning which task types the tool description names.
On T3 Code 0.1.10 with Claude Code 2.1.325, an Opus 5.5 parent passed its native Sol reviewer's task ID to
t3_background_wait. This used T3's Claude provider through a custom API-compatible proxy.Provider log sequence, November 17, 2026, UTC (ID redacted):
The rejection correctly explained that subagent IDs are excluded. The result reached the parent, and the observed impact was one unnecessary failed call.
The historical tool description referred broadly to background work and a task ID. The separate injected instruction specified a background command or Monitor. While revising the description, naming those accepted task types there too may be worth considering.
This is one historical occurrence on custom routing. Reproduction on stock routing and testing whether revised wording changes the model's behavior remain outstanding.