Skip to content

claude: read session history from the provider's Claude home - #12

Merged
ziyadakl merged 2 commits into
custom-v2from
fix/claude-fork-config-dir
Oct 8, 2026
Merged

ziyadakl merged 2 commits into
custom-v2from
fix/claude-fork-config-dir

Conversation

@ziyadakl

@ziyadakl ziyadakl commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Summary

Forking a Claude thread failed with Claude Agent SDK query failed. (cause: Session <id> not found in project directory) whenever the Claude instance sets its own Claude home (homePath → CLAUDE_CONFIG_DIR). The SDK's history helpers read CLAUDE_CONFIG_DIR from process.env and cache it, so inside the server they searched the server's home. The orchestrator rewrite (upstream pingdotgg#2829) dropped the child-process worker the old adapter used.

 ClaudeAgentSdkQueryRunner
   forkSession(input)
-    sdk.forkSession(...)                     # server's process.env → wrong Claude home
+    runHistoryWorker("forkSession", ..., input.environment)
   subagentLaunchToolUseId(input)
-    sdk.getSubagentMessages(...)             # same flaw; caller swallowed the error
+    runHistoryWorker("getSubagentMessages", ..., input.environment)

 runHistoryWorker
   spawn process.execPath [claude-history-worker | __claude-history] with the instance environment

claudeHistoryWorker.ts learns getSubagentMessages (agentId, limit).

Evidence

New ClaudeAdapterV2.queryRunner.test.ts: the server's CLAUDE_CONFIG_DIR points at an empty dir; the transcript lives in the provider's home, passed as environment.

fork a session stored in the provider's Claude home
find a subagent's launch id in the provider's Claude home
  • Before: Tests 2 failed (2) — Caused by: Error: Session 6f0c6a52-… not found and expected null to equal 'toolu_01SubagentLaunch'
    After: Tests 2 passed (2)
  • ClaudeAdapterV2.test.ts + new file: 150/150 pass. tsc --noEmit clean, vp fmt --check and vp lint clean.
  • The 2 AntigravityAdapterV2.test.ts failures in orchestration-v2/Adapters/ also fail on unchanged custom-v2.
  • Real data: the SDK getSubagentMessages with CLAUDE_CONFIG_DIR=~/.claude-pool returns the launch id for a real subagent.

Merge Danger

Door: two-way

Revert the commit to return to in-process calls. No stored data changes.

Blast Radius: small

Only Claude thread forks and the subagent launch lookup. Each now spawns one short child process (30 s timeout). Desktop builds run it with ELECTRON_RUN_AS_NODE=1, as the old adapter did. The single-executable uses the existing __claude-history subcommand.

🤖 Generated with Claude Code

Forking a Claude thread failed with "Session ... not found" whenever the
provider instance sets its own Claude home (homePath, exported as
CLAUDE_CONFIG_DIR). The orchestrator rewrite (pingdotgg#2829) called the SDK's
forkSession and getSubagentMessages inside the server. Those helpers find
transcripts through process.env.CLAUDE_CONFIG_DIR, cached on first use, so
they searched the server's home, not the instance's.

Both now run in the existing claude-history worker child, started with the
instance's environment, as the old adapter did. The subagent lookup failed
the same way but silently: its caller swallows the error.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Oct 8, 2026
Encode worker options with Schema, fail with the runner's tagged error,
and build the test's Claude homes through FileSystem and Path.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ziyadakl
ziyadakl merged commit b6523bb into custom-v2 Oct 8, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants