Repository navigation
[Agent Teams] Allow spawnTeammate to set the teammate's working directory (cwd) #9188
Replies: 1 comment
|
Still reproduces on
and It just never reaches the child. and Repro: parent cwd
Minimal fix: make |
|
Still reproduces on
and It just never reaches the child. and Repro: parent cwd
Minimal fix: make |
Uh oh!
There was an error while loading. Please reload this page.
Problem
spawnTeammategives no way to choose a teammate's working directory. Every teammate session inherits the Lead'scwd, so teammates that edit files in parallel all work in the same tree.For plugins that coordinate multiple writers (for example, by giving each teammate its own git worktree or clone), this leaves only one option: tell the teammate in the assignment message to "work only in directory X". That is advisory. The session itself, its tools, and anything resolved relative to
cwdstill point at the Lead's directory.Where the gap is (master @
5badb15)SpawnTeammateRequesthas nocwdfield:agent-team/src/types.ts#L166startContinuablewith onlypromptandparent: root:agent-team/src/roster.ts#L282-L288ContinuableStartSpec/SubagentStartRequesthave nocwdeither. The doc comment says in-process providers derive the workspace fromparent:subagent/src/types.ts#L145-L155subagent/src/child-agent.ts#L144-L147cwd:core/agent/src/index.ts#L63-L80So the session layer already supports this. The value just has no way to get there from the team API.
Proposal
Add an optional, backward-compatible
cwd:The roster would forward it to
startContinuable→SubagentStartRequest.cwd, and in-process providers would use it in place ofparentHeader.cwdwhen creating the child session.spawn_teammatecould expose the same optional parameter.Questions for the team to decide:
cwdshould fail the spawn with an explicit error rather than silently fall back to the Lead's directory.context: 'fork': should a fork be allowed to overridecwd? Forking copies conversation history, not the working directory, so allowing it seems reasonable. Either way, it would help to document it.cwdshould be stored with the teammate session so it survives a reload.Current workaround
A coordinator plugin can lease a separate checkout per teammate, include the path in the assignment message, and use a tool guard to reject
gitcommands outside that checkout. This contains git operations but not ordinary file reads and writes, which is why a realcwdat spawn time would help.Related but different: #6506 (worktree sessions and workspace grouping), #8324 / #8035 (per-teammate model selection).
All reactions