Repository navigation
Description
Summary
Forking a Claude Code thread fails right away if CLAUDE_CONFIG_DIR is set as a bb project environment variable, not in the environment of the bb host process. The forked thread goes to error with:
Command thread.start failed — Session <session-id> not found
Both forking paths fail: bb thread fork <id> and "Fork into new thread" in the UI.
Steps to reproduce
- Set the project environment variable
CLAUDE_CONFIG_DIRto a non-default Claude config directory. Do not set it in the environment of the bb host process. - Start a Claude Code thread in that project and complete at least one turn. Its session transcript is written under
<CLAUDE_CONFIG_DIR>/projects/…. - Fork the thread:
bb thread fork <thread-id>.
Expected: the fork opens with the source thread's history.
Actual: thread.start fails with Session <id> not found. If you then send a message to the forked thread, bb starts a new empty session. The source history is silently lost.
Root cause
Project env vars reach Claude Code only through the session env: config.envVars → buildSessionEnv(readConfigEnvOverrides(params.config)) in plugins/provider-claude-code/src/bridge/bridge.ts.
handleThreadFork (bridge.ts:2457) calls the Agent SDK's forkSession(params.sourceProviderThreadId, …) inside the bridge process (bridge.ts:2474). It passes no dir and no env. The SDK finds the transcript through process.env.CLAUDE_CONFIG_DIR of the bridge process and falls back to ~/.claude. It never looks in the session's configured config dir, so the transcript is not found.
Possible fixes
- In
handleThreadFork, readCLAUDE_CONFIG_DIRfromreadConfigEnvOverrides(params.config)and pass it to the fork. Today the SDK reads onlyprocess.env, so this means scoping the env for the call or using asessionStore. - Or don't fork in-process: start the session with
resume: <source>andforkSession: truein thequery()options. The CLI then forks with the correct session env.
Related: retrying the failed fork is rejected
bb thread retry <forked-thread-id> fails with Command thread.start failed — Invalid host RPC command. The host daemon rejects the retried thread.start during schema validation (apps/host-daemon/src/server-connection.ts):
ZodError: input must contain at least one entry (path: command.input)
A fork start has no user input, and retry sends thread.start again with an empty input. So a failed fork start can never be retried, whatever made it fail.
Activity
bb-slop-cop commentedon Oct 26, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotproviders,threads,provider-claude-code.confirmed-repro.Fork Claude sessions from the session's config dir and keep fork inte…
Stream Claude fork transcripts so long threads can edit and fork (#6782)
Fork Claude sessions in a worker so an oversized fork cannot crash ot…