[Issue #86] Spawn agents with cwd set to their worktree #88
Reference in New Issue
Block a user
Delete Branch "issue-86-spawn-agents-with-cwd-worktree"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Resolves the permission denied errors that occurred when spawned agents tried to access worktree files outside the main repository directory. The orchestrator now creates all worktrees upfront and passes the paths to agents.
Changes
WORKTREE_PATHto each agentWORKTREE_PATHparameter, works directly in provided worktreeWORKTREE_PATHparameter, works directly in provided worktreeWORKTREE_PATHparameter, uses provided worktree for reviewWORKTREE_PATHnot providedProblem Solved
Previously, when agents tried to
cd ../repo-issue-Xor read files in sibling worktrees, they got "Permission denied (prompts unavailable)" because the worktree paths were outside their sandbox. Now:Benefits
✅ Eliminates permission denied errors
✅ Agents work reliably with isolated worktrees
✅ Parallel agent execution is now viable
✅ Backward compatible with existing implementations
✅ Clear separation of concerns: orchestrator manages filesystem, agents do work
Closes #86
AI Code Review
Summary
This PR successfully addresses the permission denied errors that occurred when spawned agents tried to access worktree files. The changes are well-structured, backward compatible, and clearly documented.
Findings
Code Quality
Potential Bugs
Security Concerns
Style Notes
Test Coverage
Verdict
LGTM
This PR successfully resolves the sandbox permission issues. The design is clean: orchestrator creates worktrees upfront and passes paths to agents, eliminating cross-sandbox directory access. Backward compatibility ensures existing callers continue to work. Ready to merge.