@devries-cameron20 / t3code-1 / commits / ac781dcb77
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

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

Julius Marminge committed Nov 12, 2026 at 02:30 UTC ac781dcb770e80ee66fe74f5ff2058d90d4ee190
4 files changed +27 -3
apps/server/src/mcp/OrchestratorMcpService.test.ts
+22
@@ -30,14 +30,17 @@ import {
30 import { checkpointWorkspace } from "@t3tools/provider-testing/replayWorkspace";
31 import * as DateTime from "effect/DateTime";
32 import * as Deferred from "effect/Deferred";
33 +import * as Duration from "effect/Duration";
34 import * as Effect from "effect/Effect";
35 import * as Fiber from "effect/Fiber";
36 import * as Layer from "effect/Layer";
37 +import * as Option from "effect/Option";
38 import * as Queue from "effect/Queue";
39 import * as Ref from "effect/Ref";
40 import * as Result from "effect/Result";
41 import * as Schema from "effect/Schema";
42 import * as Stream from "effect/Stream";
43 +import * as TestClock from "effect/testing/TestClock";
44
45 import { CodexProviderCapabilitiesV2 } from "../orchestration-v2/Adapters/CodexAdapterV2.ts";
46 import * as CommandReceiptStore from "../orchestration-v2/CommandReceiptStore.ts";
@@ -1274,6 +1277,7 @@ describe("OrchestratorMcpService provider resolution", () => {
1277 "child run completion",
1278 "child question",
1279 "child approval",
1280 + "Node fetch's 300 s idle timeout",
1281 ] as const)("a task wait still returns on %s", (wake) =>
1282 Effect.gen(function* () {
1283 const events = yield* Queue.unbounded<OrchestrationV2StoredEvent>();
@@ -1379,6 +1383,24 @@ describe("OrchestratorMcpService provider resolution", () => {
1383 .delegateTask(scope, { task: "Review the change.", mode: "wait" })
1384 .pipe(Effect.forkChild);
1385 yield* Deferred.await(subscribed);
1386 + if (wake === "Node fetch's 300 s idle timeout") {
1387 + // Nothing is written during the wait, so undici drops the call at 300 s, before any handle.
1388 + const beforeClientTimeout = yield* Fiber.join(waiting).pipe(
1389 + Effect.timeoutOption(Duration.seconds(299)),
1390 + Effect.forkChild,
1391 + );
1392 + yield* TestClock.adjust(Duration.seconds(299));
1393 + const result = yield* Fiber.join(beforeClientTimeout);
1394 + assert.isTrue(
1395 + Option.isSome(result),
1396 + "a wait without timeoutMs was still silent at 299 s, so a Node MCP client loses the taskId",
1397 + );
1398 + if (Option.isSome(result)) {
1399 + assert.equal(result.value.taskId, taskId);
1400 + assert.isTrue(result.value.waitTimedOut);
1401 + }
1402 + return;
1403 + }
1404 ready = true;
1405 if (wake === "parent completion") {
1406 yield* Queue.offer(events, {
apps/server/src/mcp/OrchestratorMcpService.ts
+3 -1
@@ -131,6 +131,8 @@ import * as PeerForwarding from "../peer/PeerForwarding.ts";
131 import * as RemoteDelegation from "../peer/RemoteDelegation.ts";
132
133 const DEFAULT_WAIT_TIMEOUT_MS = 10 * 60 * 1_000;
134 +// Nothing is written while a task wait blocks, and Node fetch drops a silent call at 300 s.
135 +const DEFAULT_TASK_WAIT_TIMEOUT_MS = 4 * 60 * 1_000;
136 const MAX_WAIT_TIMEOUT_MS = 60 * 60 * 1_000;
137 const TASK_WAKE_EVENTS = [
138 { thread: "parent", eventType: "subagent.updated" },
@@ -1698,7 +1700,7 @@ const make = Effect.gen(function* () {
1700 ): Effect.fn.Return<OrchestratorMcpDelegateTaskResult, OrchestratorMcpFailure> {
1701 const timeoutMs = Math.min(
1702 MAX_WAIT_TIMEOUT_MS,
1701 - Math.max(1, requestedTimeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS),
1703 + Math.max(1, requestedTimeoutMs ?? DEFAULT_TASK_WAIT_TIMEOUT_MS),
1704 );
1705 const upgradeWake = threadManagement
1706 .dispatch({
apps/server/src/provider/agentContextBudget.json
+1 -1
@@ -1,5 +1,5 @@
1 {
2 "claudeSystemAppendBytes": 5597,
3 "codexAdditionalContextBytes": 7327,
4 - "mcpToolListJsonBytes": 48131
4 + "mcpToolListJsonBytes": 48130
5 }
packages/contracts/src/orchestratorMcp.ts
+1 -1
@@ -184,7 +184,7 @@ export const OrchestratorMcpDelegateTaskInput = Schema.Struct({
184 }),
185 ),
186 timeoutMs: Schema.optional(Schema.Finite).annotate({
187 - description: "Mode 'wait' only. Default 10 min. A timeout does not cancel the child.",
187 + description: "Mode 'wait' only. Default 4 min. A timeout does not cancel the child.",
188 }),
189 clientRequestId: Schema.optional(OrchestratorMcpClientRequestId),
190 runtimeMode: Schema.optional(