Claude startup fails in rapid pairs: query ended before turn attachment, termination cause obscured #37603
Summary#
On a Railway-hosted T3 server, existing Claude Agent threads repeatedly fail startup in pairs roughly 1–2 seconds apart. The server logs show ProviderAdapterProtocolError: Claude provider query ended before the turn could start. The message was never offered to the provider, but clients see only a generic Provider error. This affects both messages submitted by a human and messages submitted over MCP.
Evidence (UTC, 2026-11-16)#
For the same thread/native provider thread:
- 09:02:52.212
orchestration-v2.claude-mcp-servers-unavailable, servers[ 't3-code' ]. - 09:02:52.213
orchestration-v2.claude-wake-turn-detected. - 09:02:52.215 run ordinal 16:
ProviderAdapterTurnStartError, caused byProviderAdapterProtocolError: Claude provider query ended before the turn could start.Trace includesClaudeAdapterV2.startTurnandProviderTurnStartService.startWithHandoffs. - 09:02:53.435 another unavailable-MCP warning.
- 09:02:53.438 ordinal 17 fails on the same native provider thread.
- 09:08:33.138 ordinal 18:
Recovering provider context in a fresh native session, driverclaudeAgent, reasonuncertain_history_delivery, errorTagProviderAdapterTurnStartError.
A separate server-log query for 2026-11-15 09:00 through 2026-11-16 09:00 returned 28 startup-failure headers in 14 pairs (09:07 through 15:36 on November 15). Only the November 16 sample above has had its nested cause inspected; we are not asserting all pairs share it.
Source investigation#
At upstream main dfeaf7b13786712cc350fa35abea17715fdef987, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts defines this detail as query exit before attachment, before the prompt was offered. attachTurn emits it if the selected query is no longer current or is stopping. Query initialization catches failures; MCP registration catches errors and reports only server names. Thus the unavailable-MCP warning does not establish that MCP caused the query exit.
Expected / requested investigation#
Preserve the SDK query termination/exit cause through the startup error shown to clients, and correlate the failed run with message/admission IDs. Determine why a dead/stopping query is selected for a following startup, and whether an atomic fresh-query recovery can safely retry a prompt known never offered.
Hypotheses checked against the available sample:
- Resume: plausible (same native thread, later fresh-session fallback), not proven as root cause.
- Thread limit: no contemporaneous pids/fork diagnostic in this sample; neither confirmed nor ruled out.
- Provider limit: no 429/limit diagnostic in this sample; neither confirmed nor ruled out.
- Concurrent sends: wake detection and consecutive ordinals are visible, but no command correlation; neither confirmed nor ruled out.
This report establishes the failing adapter boundary, not the underlying SDK exit cause. We have not changed deployed provider settings or upgraded T3. Exact deployed binary revision still needs to be established; the source SHA above identifies inspected source, not the deployed revision.
Related downstream delivery/ownership work: https://github.com/iota-uz/plot/issues/503
Follow-up: confirmed SDK error and command correlation#
Local provider event logs reveal the previously hidden nested cause. At both
09:02:52.213 and 09:02:53.436 UTC, the incoming SDK result is
subtype: error_during_execution, errors: ["No conversation found with session ID: <same-native-session>"],
duration_ms: 0, duration_api_ms: 0, num_turns: 0, is_error: true.
Both query.open records resume that same native session in the same cwd.
At 09:08:33.936 a fresh session is opened (sessionId, no resume), followed by
prompt.offer at 09:08:33.938 and command lifecycle frames. The working directory
is unchanged, so this pair is not explained by a cwd switch.
Across the provider logs for 2026-11-15 09:00 to 2026-11-16 09:10 UTC, all 30 matching error results say "No conversation found with session ID"; all 30 have zero API duration and zero turns. This covers the 28 startup headers from November 15 plus the November 16 pair above.
Read-only T3 projection correlation for the November 16 pair:
- Ordinal 16: requested 09:02:50.626, failed 09:02:52.217; message author agent, source mcp (cleanup request).
- Ordinal 17: requested 09:02:52.369, failed 09:02:53.440; message author agent, source provider, with a notification (native wake), not a second MCP send.
- Ordinal 18: requested 09:08:33.038, completed 09:08:43.171; message author user, source web; fresh session recovery.
Thus invalid/missing-conversation resume is confirmed for these samples. Thread exhaustion and provider rate limits are not their immediate failing condition: the SDK explicitly rejects local conversation lookup before any API work. Two simultaneous MCP sends do not explain the inspected pair: the second run was an internal provider wake, requested after the first failure completed. Why the native transcript disappeared is not established by these logs. Please preserve this SDK error in the client-visible failure and recover a known-unoffered prompt through the missing-session fallback immediately.
tanstack-source added labelsbug
juliusmarminge closed this
Sign in to join this conversation.