Support `cwd` for `spawn_agent`

Open 💬 4 comments Opened Apr 22, 2026 by gndk

What variant of Codex are you using?

CLI

What feature would you like to see?

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.

Proposed API:

{
  "task_name": "worker_a",
  "message": "Implement the assigned slice.",
  "cwd": "/absolute/path/to/worktree"
}

Suggested semantics:

  • absolute paths are used as-is
  • relative paths resolve from the parent agent cwd
  • the child session starts with the requested cwd
  • 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.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗