[Bug]: Forking a running Claude thread replaces native history with a context handoff

Aberta
#34,856 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
42/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
typescript

Direção de pesquisa

Start with apps/server/src/orchestration-v2/CommandPolicy.ts and ProviderTurnStartService.ts, then read ClaudeAdapterV2.forkThread and the Agent SDK's forkSession behavior. Reproduce a fork at a finished turn while the parent is running, checking transcript handling for a half-written line and whether upToMessageId excludes the active turn. Done means a running Claude source can be forked with native history while the parent continues, with the open questions resolved.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Before submitting
  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.
Area

apps/server

Steps to reproduce
  1. Use the Claude provider and let a turn finish.
  2. Send another message in that thread and leave it running.
  3. Fork from the finished turn, or open a side chat.
  4. Send the fork's first message before the parent finishes.
Expected behavior

The fork resumes a native copy of the Claude session up to the finished turn, with its real tool calls, outputs and prompt cache, while the parent keeps running.

Actual behavior

The fork starts a new Claude session whose first input is a T3-written "Fork context" summary (full_thread_summary). In my case the handoff kept 5 items and dropped 6, and native tool and reasoning state was not carried over. Idle forks of the same thread fork natively.

The cause is the busy-source rule added in #26901: decideForkExecution requires !input.sourceBusy, and startup checks again. #26901 gives the reason that Claude cannot fork a running session.

Why Claude may not need the fallback

The Agent SDK's forkSession doesn't use the live session. It reads the session's .jsonl transcript, cuts it at upToMessageId, rewrites UUIDs, and writes a new transcript. It has no check that the source is idle. A finished turn's messages are already in the transcript, so forking at that point should not need the source to stop.

The adapter's own guards in ClaudeAdapterV2.forkThread (the active-turn refusal and closeLiveQueryForNativeThread) look at the calling session's state. For a new fork, that is the target session, not the running parent. So I couldn't confirm from the code why a busy Claude fork failed before #26901.

#29239 (open, waiting for maintainer confirmation) adds an optional provider capability for native forks while the source runs, and enables it for Codex only. If that lands, Claude could set the same capability, possibly after an adapter change.

Open questions before enabling it for Claude
  • What failed when a Claude fork of a running thread was tried before #26901? A repro or log would show whether the limit is in the SDK, the CLI, or the adapter.
  • Does forkSession handle a source transcript that the running session is still appending to, including a half-written last line?
  • Is the fork's upToMessageId always a message in the finished turn, so nothing from the running turn gets in?
Impact

Minor bug or occasional failure

Version or commit

Seen on a personal fork built on nightly 0.1.8-nightly.20261109. The rule is unchanged on upstream 3a30b011c3.

Workaround

Wait for the parent to go idle before sending the fork's or side chat's first message.

Filed by Claude Opus 5.5 through Claude Code in T3 Code.

Linguagem predominante
TypeScript
Estrelas
24.8k
Forks
6.4k
Merge médio
4h 16min
PRs com merge (30d)
352

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de pingdotgg/t3code

Todas as issues de pingdotgg/t3code

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.