Skip to content

[Bug]: A fresh Claude thread is never retried after a startup or MCP registration timeout, so webhook-started runs are lost #37935

Closed

Description

@krazar

Note

🤖 Written by Claude Code (Opus 5.5) on behalf of the reporter, from the server logs and the 0.1.9 source.

Before submitting

Area

apps/server

Steps to reproduce

  1. Run the T3 server as a systemd user service on Linux, with agent scopes on.
  2. Create a webhook scheduled task that starts a new thread per delivery, for example one per GitHub pull_request event.
  3. Deliver about 15 events within two minutes, as a push to several PRs does. 13 to 20 Claude sessions then start together, each with its stdio MCP servers.
  4. app-t3code-agents.slice goes over its MemoryHigh, and the kernel throttles every process in it.
  5. Some of the new Claude processes do not answer setMcpServers within 90 s. T3 kills them, and their runs fail with "Claude timed out while registering its MCP tools".

Deterministic variant: lower the slice's MemoryHigh to just above current usage (systemctl --user set-property --runtime app-t3code-agents.slice MemoryHigh=…, as in #36667), run a memory-heavy agent, then deliver one webhook event.

Expected behavior

A transient start failure of a fresh session is retried, as a resumed session's already is. For example: one retry after a short backoff, or a start that waits while the slice reports full memory pressure. A webhook-started run has no user watching it, so nobody retries it by hand.

Actual behavior

Only resumed sessions get a retry. In 0.1.9, ClaudeAgentSdkQueryRunner.open ends with:

retry({ times: 1, while: (error) => input.options.resume !== undefined && isClaudeMcpRegistrationTimeoutError(error.cause) })

A fresh thread fails once and stays failed. Its webhook delivery was accepted, so nothing redelivers it, and the run is lost.

#30166 (in v0.1.10) gives boot its own 5-minute deadline, which should make this rarer. Its description keeps the retry rule as is ("On fresh sessions there is no retry, so the turn just fails"), so a fresh start that still times out, now or with "Claude timed out while starting up", is still dropped.

Impact

Major degradation or frequent failure

Version or commit

0.1.9. The retry rule is unchanged in v0.1.10, according to #30166.

Environment

Ubuntu 24.04 KVM VM: 4 vCPU, 12.5 GB RAM, no swap. T3 server 0.1.9 as a systemd user service. Claude Code 2.1.325, Agent SDK 0.3.321. Each session runs about 8 stdio MCP servers plus the claude.ai connectors, about 600 MB in all.

Logs or stack traces

# 116 of 1,810 t3code-claude-*.scope units since 2026-10-29 lived 88-93 s (journalctl --user, Started -> Consumed).
# Most started while 12-20 Claude scopes were alive. The median across all starts is 5.
# One burst: 14 scopes started between 01:10:41 and 01:12:24. Those started at 01:12:11, :15 and :19
# stopped at 01:13:41, :45 and :49, exactly 90 s later, after 13-18 s of CPU each.

# app-t3code-agents.slice since server start (MemoryHigh 6271096832 = RAM/2, MemoryMax 9406645248):
memory.events   high 181476842   max 0   oom_kill 0
memory.pressure full total=15059354775   # ~4.2 h with every task in the slice stalled
cpu.stat        user_usec 16932123162   system_usec 53003342835

WARN orchestration-v2.claude-mcp-registration-timeout { threadId: '<thread>', providerSessionId: '<session>' }
ERROR orchestration V2 provider turn start failed
  ProviderAdapterTurnStartError: Failed to start run <run> on claudeAgent provider thread <thread>.
    [cause]: ClaudeAgentSdkQueryRunnerError: Claude Agent SDK query failed.
      [cause]: ClaudeMcpRegistrationTimeoutError: Claude timed out while registering its MCP tools. Retry the turn; if it keeps failing, check Claude and the server logs.

Workaround

Less memory per session and some room to absorb a burst:

  • Swap with zswap in front, so idle MCP servers can leave RAM.
  • Run npm MCP servers without the npx -y wrapper, which keeps an npm exec process (about 50 MB) next to each server.
  • Turn off the user MCP servers that automation projects do not use.

Upgrading to v0.1.10 should also help, through #30166.

Activity

  1. juliusmarminge commented on Nov 17, 2026

    @juliusmarminge
    Member

    A fix for this was proposed in #37939, but when the reported steps were run in the real app the problem did not appear.

    What was run on 2904c397ad, the commit before this change:

    On both commits, configured a webhook task creating a fresh Claude thread per delivery. Lowered only the server-owned agent slice's MemoryHigh to 1 MiB, delivered one event, observed HTTP 202 and a real five-minute initialization timeout, then removed memory pressure before replacement initialization. Both commits launched a replacement with a different native session UUID, recorded exactly one prompt.offer after successful opening, returned STARTUP_RECOVERED, and completed the thread. Earlier setup deliveries on both sides used an unavailable model slug; both corrected deliveries used the working haiku alias. All servers, agent slices, watchers, scratch files, and worktrees were stopped or removed.

    How: Manual real-server comparison: separate worktrees and databases, Linux systemd user services with agent scopes, real Claude Haiku, synthetic projects and webhook tasks. Captured server output, native protocol events, process UUIDs, kernel memory counters, and real CLI thread output. Replay cannot exercise this provider-specific behavior.

    Could you share the exact steps, what you see, and the version and platform you are on? The pull request is closed for now; the fix is picked up again once the problem can be shown.

  2. EladCohen08 commented on Nov 19, 2026

    @EladCohen08

    Additional 0.1.9 reproduction on Ubuntu 24.04 (12 cores, 24 GB RAM): manually created Claude chats failed repeatedly before a prompt reached the model, across more than one Claude account profile. One server trace measured ClaudeAgentSdkQueryRunner.open at 90,374.6 ms and recorded orchestration-v2.claude-mcp-registration-timeout followed by ClaudeMcpRegistrationTimeoutError from setMcpServers.

    The host was under severe memory pressure (memory PSI some approximately 86%, full approximately 55%; many concurrent Claude processes). Separate no-model-prompt SDK handshake probes succeeded in 24.1 seconds with strict/empty configuration and 47.5 seconds with normal settings. This supports slow startup under pressure as a contributor; it does not identify one faulty connector or prove a specific cgroup limit caused it.

    A temporary local 90 -> 180 second deadline change was only a mitigation. We are removing it and upgrading to the official 0.1.10 release to keep automatic updates and use the upstream startup changes referenced here. This comment adds older-version evidence, not a claim of a 0.1.10 regression.

    Reported with Codex on the user's request.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs more infoInitial triage showed no bug. Awaiting more info

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions