Skip to content

fix(server): delegate_task wait returns its task handle before Node fetch's 300 s timeout - #35032

Merged
juliusmarminge merged 2 commits into
mainfrom
factory/issue-11168-a1794473726
Nov 12, 2026
Merged

juliusmarminge merged 2 commits into
mainfrom
factory/issue-11168-a1794473726

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

OrchestratorMcpService.awaitTask (the delegate_task mode "wait" path, local and peer) used the shared 10-minute DEFAULT_WAIT_TIMEOUT_MS and sent nothing to the HTTP response while it waited. Node/undici MCP clients, including T3's AcpMcpStdioBridge fetch, dropped the call at 300 s with no taskId, so the documented waitTimedOut recovery never happened for the default budget. awaitTask now uses its own DEFAULT_TASK_WAIT_TIMEOUT_MS of 4 minutes, so an unbounded wait returns taskId/childThreadId with waitTimedOut: true before common client timeouts. t3_thread_wait and secret-request waits keep their 10-minute default, and an explicit timeoutMs is still honored up to the 60-minute max. The delegate_task timeoutMs description now says 'Default 4 min.' That shortened the tool list JSON by 1 byte, so agentContextBudget.json goes from 48131 to 48130. The paid MCP tool-use eval was not run, since only the number in the description changed. No new regex or parser. The repro test row from factory/repro-11168 is kept; it failed on base (verified by stashing the fix) and passes now. The bug was not reproduced end to end with a dev server; the proof is that test.

Fixes #11168

Reproduction on main

Commit b68aedf (origin/main). Started the worktree dev server with T3CODE_DEV_SEED=0 (fresh database). Registered a throwaway local ACP provider instance whose prompts never finish. Added a scratch git repo as a project and started a parent thread on it; the agent received T3's stdio MCP bridge (bin.ts acp-mcp-bridge) config. (1) Spawned that bridge with the same env and sent initialize, then tools/call delegate_task {target: probe/hang, mode: "wait"} with no timeoutMs and no clientRequestId. At +301.0 s the bridge answered {"error":{"code":-32603,"message":"T3 Code MCP bridge request failed: fetch failed"}}, with no taskId or childThreadId. (2) The same call as a bare Node 26 fetch to the /mcp endpoint failed at +300.9 s: TypeError fetch failed, cause HeadersTimeoutError UND_ERR_HEADERS_TIMEOUT. The server sends no response headers until the wait ends. Afterwards orchestration_v2_projection_subagents showed both children still status=running (completionWake upgraded to "always"), with clientRequestId null, so a retry cannot dedupe. Failing test: one new row in the existing 'a task wait still returns on %s' table in apps/server/src/mcp/OrchestratorMcpService.test.ts. It forks delegateTask mode wait without timeoutMs on a child that never wakes, advances TestClock 299 s and requires a result with the taskId and waitTimedOut=true. It fails on main and passes when DEFAULT_WAIT_TIMEOUT_MS is lowered to 240 s (that change was reverted).

Evidence

Start a never-finishing synthetic ACP parent on a fresh real server. Call delegate_task mode wait through both T3's stdio bridge and bare Node fetch, omitting timeoutMs and clientRequestId. Await the actual responses and inspect persisted child state.

Before After
b68aedfdb7 77fd2ef8cb
Before: timeout without task handles After: returned handles and waitTimedOut true
Fetch fails at 301.0s; bridge fails at 301.1s. Neither returns a handle. Fetch returns at 240.6s; bridge returns at 241.5s. Both include taskId, childThreadId, status running, and waitTimedOut true.
Timed transcript video Timed transcript video
Raw client transcript Raw client transcript
Persisted running children Persisted running children

Videos are readable replays of actual timestamped client output at 10x speed, with long handles abbreviated; raw JSON contains the full responses. Both sides used Node 26.12.1, independent fresh databases, and the same synthetic provider and driver. Both children remained running on each side.

Client driver, synthetic ACP provider, setup and seed commands, video renderer.

AI-assisted; verified with the tests and tools listed above.

Not shown:

  • Automatic agent retry and consequent duplicate dispatch were not exercised; the missing-handle failure and surviving children were observed directly.
  • Explicit timeoutMs overrides and other wait APIs were not exercised; this proof covers delegate_task mode wait with the default timeout.

Tests

vp test run src/mcp/OrchestratorMcpService.test.ts -t "300 s" without the fix: 1 failed (AssertionError 'still silent at 299 s'). With the fix: vp test run src/mcp/OrchestratorMcpService.test.ts src/mcp/toolkits/core.test.ts: 91 passed. vp test run src/provider/AgentContextBudget.test.ts: 2 passed after the budget update. vp run check:changed: format, lint, knip, graphql, typecheck (37 packages) and tests (4 files) all pass.

Not in this change

  • An explicit delegate_task timeoutMs above about 300 s still lets a Node client time out with no handle. Capping it, or sending early headers or progress, would be a separate design change.
  • t3_thread_wait's 10-minute default has the same silent-wait problem; open PR fix(mcp): default t3_thread_wait to 50 seconds so clients don't time out first #18540 addresses it separately.
  • The thread-wait input schema comment ('Default 10 minutes.') and the tool's timeout guidance were left unchanged, since that path is not part of this fix.

AI-assisted; verified with the tests and tools listed above.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 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.

delegate_task mode:"wait" dies at the client ~5 min ceiling and returns no taskId, causing duplicate child dispatch

1 participant