Repository navigation
Description
What happened
I forked a long Claude thread from one of its earlier assistant messages. Every send in the fork fails immediately with "Provider turn failed to start — Claude Agent SDK query failed." (three tries).
Diagnosis
The source thread has one provider thread whose native Claude session was A for runs 1–42. Starting run 43, delivering a pending merge-back (fork_delta_summary) failed with ContextHandoffBudgetError (A was at ~788k/1M tokens), so ProviderTurnStartService took the provider_resume_fallback path: a new native session B seeded with a full_thread_summary. B was written onto the same provider thread (nativeThreadRef → B), while provider turns 1–42 keep native message IDs that only exist in A's transcript.
Forking at run 42 then pairs the two:
resolveClaudeForkUpToMessageIdreturns run 42'snativeTurnRef(a message in A) —ClaudeAdapterV2.ts:2321forkThreadtakes the session fromgetNativeThreadId(sourceProviderThread)= B —ClaudeAdapterV2.ts:12705- SDK
forkSession(B, { upToMessageId })→Message <id> not found in session <B>
The fork transfer's sourcePoint already records providerThreadRef = B next to a providerTurnRef from A. At dispatch, decideForkExecution sees same provider + strong native source (Orchestrator.ts:7563) and picks native_fork on every send, and this build has no fallback, so the fork can never start.
main still picks the session this way. c3e5bfc (#27729) falls back to a fresh portable session after a failed fork, which unblocks it but drops native history A still has. Fix idea: record the native session per provider turn (or start a new provider thread on resume-fallback) and fork from the session owning the anchor.
Steps to reproduce
- Use a Claude thread until its native session is close to the context limit (here ~788k/1M).
- Get the thread onto a new native session via
provider_resume_fallback. Here: fork it, merge the fork back, then send in the source; delivering the merge-back exceeds the handoff budget and the turn starts in a new session with a full-thread summary (two "Context handoff" markers appear). - Fork the source from an assistant message from before those markers.
- Send any message in the fork → "Provider turn failed to start / Claude Agent SDK query failed". Every resend fails the same way.
Version
0.1.10-nightly.20261111.4544 (1264c20) — server; desktop app on the same nightly
Environment
Server: Linux x64 (Debian, kernel 6.12), Node 26.12.1, Claude Code 2.1.322, claude-agent-sdk ^0.3.321. Client: T3 Code Desktop on macOS connected to that remote server.
Evidence
# server.trace.ndjson, first send in the fork
ClaudeAgentSdkQueryRunner.forkSession Failure
at ClaudeAdapterV2.forkThread / ProviderTurnStartService.loadFromProvider
[cause]: Message 90dbad04-… not found in session 5d21c86a-…
# provider events (fork), 5 retries per send:
session.fork {sessionId: 5d21c86a-…, upToMessageId: 90dbad04-…}
# Claude transcripts
65ebbd59-….jsonl: last assistant uuid 90dbad04-… (session A, runs 1-42)
5d21c86a-….jsonl: starts with full_thread_summary handoff, runs 1-42
# source thread, run 43
deliverContextHandoffs Failure: ContextHandoffBudgetError
→ provider_resume_fallback; one provider_threads row for runs 1-43, nativeThreadRef=5d21c86a-…Related issues
#24152: same shape (one provider thread spanning several Claude sessions) but resume after /clear, not fork. #27729 / c3e5bfc masks this rather than fixing the session choice. #22198: budget error → fresh-session handoff (closed).
Fix applied or workaround
With the user's approval, edited two fork-only rows in statev2.sqlite (backup kept): set the pending fork transfer's sourceProviderInstanceId to a non-matching value so dispatch picks portable_context, and cleared the fork provider thread's forkedFrom. The next send started a fresh Claude session with a full_thread_summary and ran normally; the field was then restored. Source thread untouched.
Filed by
Claude Code (claude-opus-5-5) via T3 Code triage
Activity
juliusmarminge commentedon Nov 12, 2026
I tried to reproduce this on the current build and could not.
Commit 1a1f9ac (origin/main). I could not do an end-to-end run: it needs a real Claude session pushed close to its 1M-token context so a merge-back hits ContextHandoffBudgetError, and first-party Claude is not available on the VMs. Instead I added an orchestrator-level test to apps/server/src/orchestration-v2/ThreadFork.execution.test.ts. It runs the real Orchestrator, EffectWorker and ProviderTurnStartService against a fake Claude adapter whose forkThread fails like the SDK when the session doesn't hold the anchor message. The seeded source thread has one provider thread whose nativeThreadRef is session B. Run 1 has an attempt with nativeThreadId=A and a provider turn whose nativeTurnRef is a message in A. Run 2 has an attempt in B, which is the state a resume fallback leaves. The test forks from run 1 and sends a message. Observed on main: forkThread is called with session B, fails with 'Message native-message-a not found in session native-session-b', and after the retries the run falls back to a fresh portable session with the system notice 'Could not fork the source conversation natively (Message native-message-a not found in session native-session-b). Started a fresh session with its history.' So the native fork never succeeds. The other 14 tests in the file pass.
Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.