t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: t3_thread_wait returns timedOut after ~46 s regardless of timeoutMs

Open xande opened this issue 1 week ago • 2 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/server (the T3 MCP tool t3_thread_wait)

Steps to reproduce

  1. Have thread A start a long-running turn in thread B (any turn that runs for several minutes).
  2. From thread A, call t3_thread_wait with { threadId: <B>, timeoutMs: 600000 } (also tried with untilDelegatedWorkSettled: true).
  3. Note when the call returns.

Expected behavior

The call blocks until B's run finishes or about 600 s pass, whichever comes first.

Actual behavior

Each call returned {"status":"running","timedOut":true} after about 46 s. Five consecutive calls against the same running thread, all with timeoutMs: 600000 and untilDelegatedWorkSettled: true, returned after 46.4 s, 46.6 s, 46.1 s, 47.0 s and 45.6 s, measured from the tool-call timestamps in the calling thread's activity log. The sixth returned completed when B's run ended.

Separately, a t3_thread_wait with timeoutMs: 300000 on the calling thread's own running thread returned timedOut: true after 1.2 s. That may be intended (a thread can't wait on itself), but then an error would be clearer than timedOut.

Impact

Minor bug or occasional failure. An orchestrating agent that "waits on a worker" ends up polling in a loop, which costs tokens. A worker that ends silently (for example a crash) is only noticed on the next poll.

Version or commit

0.1.6-nightly.20261031.3977

Environment

Linux (Debian 13, kernel 6.12), Claude Code provider (claude-opus-5-5), full-access runtime mode.

Workaround

Don't loop on t3_thread_wait. Have the worker thread message the orchestrator with t3_thread_send at each milestone, and end the orchestrator's turn so those messages wake it.

xande avatar Nov 19 '26 20:11 xande

Root cause on current main: the server clamps the requested timeout to 45 s and says so nowhere.

  • apps/server/src/mcp/OrchestratorMcpService.ts:147-148: DEFAULT_WAIT_TIMEOUT_MS = 30_000, MAX_WAIT_TIMEOUT_MS = 45_000 ("Return recoverable handles before common MCP client timeouts expire").
  • apps/server/src/mcp/OrchestratorMcpService.ts:3775-3778: waitForThread passes Math.min(MAX_WAIT_TIMEOUT_MS, Math.max(1, input.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS)).
  • packages/contracts/src/orchestratorMcp.ts:589: timeoutMs: Schema.optional(Schema.Finite) with no description, and the tool description (apps/server/src/mcp/toolkits/orchestrator/tools.ts:297-299) does not mention the cap; the result carries no effective timeout.

Seen again on 0.1.11-nightly.20261119: timeoutMs 3,600,000 and 600,000 both returned timedOut: true after about 46 s. If the cap is intended, documenting it on timeoutMs (and returning the applied value) would stop agents from treating each return as a full wait.

kibartas avatar Nov 24 '26 11:11 kibartas

Filed by Claude Opus 5.5 on behalf of Davies.

Still reproduces on 0.1.14-nightly.20261127.5319 (macOS, Claude Code provider, claude-opus-5-5). Five consecutive calls with timeoutMs: 1800000 against the same running thread each returned {"status":"running","timedOut":true} after about 45 to 60 s, with no next field.

The tool description makes the clamp harder to work around than the clamp itself:

  • It says "On timeout, with next end your turn; without, call again." A timed-out result never carries next here, so a caller that follows the description loops one call per 45 s for the whole run. A 30-minute child run costs about 40 calls.
  • Nothing in the description mentions the 45 s cap. The caller asked for 30 minutes and reported "waited 30 minutes" to its user after about 1 minute.

What would fix it for orchestrators, in order of preference:

  1. A completion notification for threads started with t3_thread_launch, like the background-task notification delegate_task already gives, so the launcher is re-invoked when the child's run settles instead of polling. (#26293 covers the reverse direction, a child reporting back.)
  2. Return next on a timed-out wait, so the documented "end your turn" path is reachable.
  3. State the cap in the tool description and echo the effective timeout in the result, for example "effectiveTimeoutMs": 45000.

daviesayo avatar Nov 27 '26 23:11 daviesayo