You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add an optional cwd parameter to spawn_agent, including the MultiAgentV2 tool surface.
Parallel subagent workflows often need one worker per isolated checkout or worktree. Today a spawned
subagent inherits the parent session cwd, so callers must rely on prompt instructions such as “work in
this directory.” That is not a reliable boundary for tool execution, hooks, sandboxing, or git-root
checks.
A per-spawn cwd would let the orchestrator start each subagent in the checkout it owns.
reject a requested cwd that would grant access outside the parent’s sandbox
recompute the child file-system sandbox policy relative to the requested cwd when applicable
Additional information
Spawned agents are already created from a child Config, and session/tool execution already has a
cwd. This request is to expose a per-spawn cwd override on spawn_agent and validate/apply it before
the child session starts.
Reacted by Panic, Rob Sale, JJ Liebig, wcy1231, bumbuboon, anzax, Ignat Remizov, junio, Mete Polat, Georgi Matev and 4 more
cwd is often the subagent's ownership boundary, not just a shell convenience.
In multi-agent workflows, a parent/orchestrator agent may delegate work to workers that each own a different package, checkout, or worktree. Those locations can have different:
AGENTS.md instructions
skill discovery
repo-local config
hooks
git roots
sandbox assumptions
If the spawned agent only inherits the parent cwd, then prompt instructions like "work in this directory" are not a reliable substitute for actually starting the child session there.
Worker/reviewer use case
This becomes especially important when subagents are used as real workers or reviewers, rather than short one-off helpers.
The orchestrator should be able to keep high-level context while starting each worker in the environment that defines its actual task boundary.
Suggested behavior
I agree with the proposed semantics:
add an optional per-spawn cwd
resolve relative paths from the parent cwd
validate the requested cwd against the parent sandbox
apply the cwd before the child session starts
This would make multi-agent workflows much more robust and would align instruction discovery, skill discovery, hooks, shell tools, and git behavior with the subagent's intended scope.
Do:
* Task A
* Task B
* Task C
in parallel using subagents. Spawn one subagent per task with `git_worktree`, each on a unique `agent/...` branch and sibling worktree. After they finish, review and merge their branches back into this workspace, resolving conflicts and running tests.
This would be a fantastic enhancement for aidlc orchestration in more complex enterprise environments with tasks spanning multiple repos. Today one needs to externally orchestrate harness launches in the right root in order to get execution to pickup agents.md and skills for other repos.
Adding a Windows use case for an explicit cwd on child-agent launch. On Nov 11, 2026, a child agent assigned to work in a different project started in its parent’s working directory and needed explicit steps to load the intended project instructions. Running a command after changing directories does not show that the agent started in the right project or automatically read its instructions. Please expose a way to specify the child’s starting directory and verify which project instructions were loaded.
Activity
PratikRai0101 commentedon Apr 22, 2026
Hey, I would like to work on this, I will open a draft PR for this.
JJLiebig commentedon May 2, 2026
That would be really useful for multi agent orchestration to not step on each other's toes!
wcy1231 commentedon May 7, 2026
Why this matters
cwdis often the subagent's ownership boundary, not just a shell convenience.In multi-agent workflows, a parent/orchestrator agent may delegate work to workers that each own a different package, checkout, or worktree. Those locations can have different:
AGENTS.mdinstructionsIf the spawned agent only inherits the parent
cwd, then prompt instructions like "work in this directory" are not a reliable substitute for actually starting the child session there.Worker/reviewer use case
This becomes especially important when subagents are used as real workers or reviewers, rather than short one-off helpers.
The orchestrator should be able to keep high-level context while starting each worker in the environment that defines its actual task boundary.
Suggested behavior
I agree with the proposed semantics:
cwdcwdcwdagainst the parent sandboxcwdbefore the child session startsThis would make multi-agent workflows much more robust and would align instruction discovery, skill discovery, hooks, shell tools, and git behavior with the subagent's intended scope.
SanjoSolutions commentedon Jun 9, 2026
Implemented in https://github.com/SanjoSolutions/codex/tree/feature/worktree-backed-subagent-spawns
Usage prompt:
Or with this skill:
gmatev commentedon Sep 24, 2026
This would be a fantastic enhancement for aidlc orchestration in more complex enterprise environments with tasks spanning multiple repos. Today one needs to externally orchestrate harness launches in the right root in order to get execution to pickup agents.md and skills for other repos.
unknowntruthtarot commentedon Nov 16, 2026
Adding a Windows use case for an explicit
cwdon child-agent launch. On Nov 11, 2026, a child agent assigned to work in a different project started in its parent’s working directory and needed explicit steps to load the intended project instructions. Running a command after changing directories does not show that the agent started in the right project or automatically read its instructions. Please expose a way to specify the child’s starting directory and verify which project instructions were loaded.