[Bug]: Forking a thread fails on Claude instances with a custom homePath #18260
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#
- Add a Claude provider instance with a custom home, e.g.
"config": { "homePath": "~/.claude-2" }. - Run at least one turn on a thread using that instance.
- Fork the thread and send a message in the fork.
Expected behavior#
The fork starts a turn from the parent's Claude session.
Actual behavior#
The turn fails to start ("Provider turn failed to start: Claude Agent SDK query failed."). session.fork is retried 5 times in about 2s, and every attempt fails with:
Session <id> not found in project directory for <cwd>
The session transcript exists under the instance's home (~/.claude-2/projects/<cwd-slug>/<id>.jsonl), but the SDK searches the default ~/.claude.
Cause: ClaudeAgentSdkQueryRunner.forkSession (apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts) calls the SDK's forkSession in the server process with only dir and upToMessageId. The instance's CLAUDE_CONFIG_DIR is only applied to query subprocesses, so the fork resolves sessions against the server's own environment. getSubagentMessages in the same runner is called the same way and probably has the same problem.
apps/server/src/claudeHistoryWorker.ts (and the __claude-history subcommand) exist to run these SDK history helpers in a separate process with the provider's environment, but nothing in the V2 adapter starts that process.
Default-home Claude instances are unaffected, which is why forking fails only for some Claude threads.
Impact#
Major degradation or frequent failure
Version or commit#
T3 Code (Nightly) desktop; main @ ee7924ff7f
Environment#
macOS (Darwin 25.6.0), desktop app, Claude provider instance with custom homePath, claude-opus-5-5
Logs or stack traces#
ProviderAdapterForkThreadError: Failed to fork claudeAgent provider thread provider-thread:provider:claudeAgent:native-thread:pending%3Arun%3Athread%3A<parent>%3Aordinal%3A1.
at ClaudeAdapterV2.forkThread
at orchestrationV2.providerTurnStart.start
[cause]: ClaudeAgentSdkQueryRunnerError: Claude Agent SDK query failed.
at ClaudeAgentSdkQueryRunner.forkSession
[cause]: Error: Session d481b7d4-0d29-4891-a74b-92cfb137b65e not found in project directory for /Users/<user>/Repos/<project>
Workaround#
Keep working in the parent thread instead of forking, or fork only threads on a Claude instance that uses the default ~/.claude home.
afaict this breaks using cliproxyapi since that requires different auth than the default .claude dir contains.
Still reproduces on Linux (Debian 13) with T3 Code nightly
0.1.1-nightly.20261019.3360, claude-opus-5-5. Claude instance with a customhomePath; the parent's transcript exists at<homePath>/projects/<cwd-slug>/<id>.jsonl, and the fork fails 5 times in ~2s withSession <id> not found in project directory for <cwd>, same stack as above. So it isn't macOS-specific, and #15040 hasn't landed in nightly yet.Note
Grok responding on behalf of Julius.
Fixed by #18662, now on main: forking a Claude thread on an instance with its own home runs the fork through the history worker with that instance's
CLAUDE_CONFIG_DIR, so the parent session is found. The same lookup for resumed subagents (getSubagentMessages) is tracked separately in #17596.juliusmarminge closed this
Sign in to join this conversation.
Note
Grok responding on behalf of Julius.
Thanks, confirmed on main:
ClaudeAgentSdkQueryRunner.forkSessionstill calls the SDK in the server process with onlydir/upToMessageId, so a customhomePathinstance'sCLAUDE_CONFIG_DIRis ignored.The fork fix is part of the open PR #15040 ("Bug 19: Claude forks ignore a custom
CLAUDE_CONFIG_DIR"), which is now linked to close this issue. The same-causegetSubagentMessageslookup is covered separately by #17596. The earlier standalone fix #15598 was closed without merging.Until it lands, forking works on instances that use the default
~/.claudehome.