Repository navigation
feat(server): run project worktree setup for Claude subagent worktrees - #127
Merged
Merged
Conversation
Claude Code creates the worktree for an `isolation: "worktree"` subagent itself, so T3's files to copy, setup script, and Conductor environment variables never reached it. A SubagentStart hook now prepares that worktree through the project setup runner before the subagent's first tool call, waiting only for non-async scripts. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude Code creates the worktree for an
isolation: "worktree"subagent itself, so T3's worktree preparation never ran there. Files to copy weren't copied, the setup script didn't run, and the project's Conductor environment variables never reached it.Fix
SubagentStartSDK hook. I checked against the real CLI (2.1.286) that this hook fires after Claude creates the subagent's worktree and before its first tool call, with the worktree ascwd, and that Claude waits for the hook to finish.cwddiffers from the session's own, the hook callsSubagentWorktreeSetup.prepare. Each worktree is prepared at most once.ProjectSetupScriptRunner.runForThreadfor the parent thread's project. Files to copy, script selection (T3 setup action first, then Conductorscripts.setup) and theCONDUCTOR_*/environment_variablesenv all match what a thread's own worktree gets. Output goes to asubagent-setup-<agentId>terminal on the parent thread.SubagentWorktreeSetup.layersits beside the provider layers, andinstallLive, at the top of the runtime layers, plugs in the real implementation. Without the install (as in tests),preparedoes nothing.Scope
WorktreeCreate/WorktreeRemovewould mean re-implementing its worktree creation.docs/fork-differences.mdand the Conductor section ofdocs/user/project-settings.md.Testing
vp test run src/provider/Layers/ClaudeAdapter.test.ts(148 pass, including a new hook test) andsrc/project/SubagentWorktreeSetup.test.ts(3 new).tsc --noEmitforapps/serveris clean.server.test.ts > flushes more than one tool chunk before the synchronization markerfails, but it fails onmainas well.Done by Claude Opus 5.5 in Claude Code (via T3 Code).
🤖 Generated with Claude Code