Repository navigation
fix(server): delegate_task wait returns its task handle before Node fetch's 300 s timeout - #35032
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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:
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
AI-assisted; verified with the tests and tools listed above.