Repository navigation
feat: let agent definitions set the default subagent isolation - #151
Conversation
A custom agent's front matter can set isolation: shared, worktree or workspace. spawn_agent uses it when the call sets no isolation; an explicit isolation, shared included, wins. It applies only with the fork-subagent-isolation experiment.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…worktree isolation
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08a2dcb3b2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Closing and reopening only to make GitHub recompute the merge ref against current main ( |
The merge ref now points at current main ( |
Merge evidence for head
|
Part of #9. Today a caller picks a subagent's isolation per call, with the
isolationargument ofspawn_agent. An agent type that should always work on its own branch, such as a fixer, needs every caller to remember that argument.With experiment
fork-subagent-isolationon, a custom agent definition can now setisolation: shared | worktree | workspacein its front matter.spawn_agentuses that value when the call sets noisolation.isolationon the call wins,sharedincluded.repo_pathandbase_branchwork with a worktree from either the call or the definition. A definition default without them creates the worktree from the chat's workspace directory and its current branch, as a call withisolation: worktreeand no other options does. With any other resulting isolation they fail withrepo_path and base_branch need isolation worktree.isolationis ignored and every spawn is shared.base_type.The
spawn_agentdescription gets one sentence that says a custom agent type can set the isolation.Limits
A stored definition, or a workspace agent file, that already has an
isolationkey with another value now fails to parse, so its agent type can't be spawned until the key is fixed. Before this change the key was unknown and only produced a warning.coderd/x/chatd/ARCHITECTURE.mdgets aTODO(ibetitsmike)for the definition default instead of final text, per the chatd rule that the human author writes that document. Codex flagged it on08a2dcb3b2; not changed.Code
codersdk/workspacesdk/fork_agentdefinition.go:AgentDefinition.Isolationand theisolationkey with its validation.coderd/x/chatd/fork_isolation.go:subagentIsolationOfreplacessubagentIsolationFromContext, falls back to the definition, and checksrepo_pathandbase_branchagainst the resulting isolation. Thespawn_agentwrapper passes no isolation when the call sets none, so the definition applies, and addsisolation,branchandworktree_path(or the workspace name) to the result whenever the child's row isn't shared.coderd/x/chatd/fork_subagents.go: the call site.coderd/x/chatd/ARCHITECTURE.md: a TODO for the default.Tests
TestForkSpawnIsolationDefinitionDefault(chatd, real database, fake worktree agent), with a personal definitionfixerthat setsisolation: worktree:NoIsolationArg: a spawn ofpersonal/fixerwithoutisolationcreates one worktree, storesworktreeon the child's row and returns its branch.RepoPathWithoutIsolationArg: the same spawn withrepo_pathand noisolationcreates the worktree from thatrepo_path. It failed before08a2dcb3b2withrepo_path and base_branch need isolation worktree, which UAT found.ExplicitShared:isolation: sharedcreates no worktree and storesshared.IsolationExperimentOff: without the experiment, the spawn is shared.TestParseAgentDefinition/CoderKeysparsesisolation: worktree, andTestParseAgentDefinitionErrors/BadIsolationrejectsisolation: container.Negative controls, each reverted after the run, each make a named case fail: ignoring the definition (
NoIsolationArg), letting the definition win over an explicitshared(ExplicitShared), dropping the experiment check (IsolationExperimentOff), and dropping the parser validation (BadIsolation).go vetandgofmtpass on both packages, andgo test ./coderd/x/chatd/...and theTestParseAgentDefinitiontests pass.UAT
Ran on 2026-11-10 on the
:3200fork branch server built at this head (v2.39.1-devel+08a2dcb3b2,fork-subagent-isolationon), as a member user, in real chats on a Docker workspace whose agent has no directory set. A personal definitionfixersetisolation: worktree.spawn_agentwithtype: personal/fixer,repo_path: /home/coder/projand noisolation: the result hasisolation: worktree, branchagent/fixer-by-default-7de358fdand a worktree under/home/coder/.coder/worktrees/proj/. The child committed a file there, andwait_agentreturneddiff_summary.commits: 1. On the previous head (90e67455c6) this same call failed withrepo_path and base_branch need isolation worktree, which is the bug08a2dcb3b2fixes. Withoutrepo_path, the earlier head already failed only withthe workspace agent has no directory; set repo_path ..., which shows the definition default was applied.spawn_agentwithtype: personal/fixerandisolation: shared: the result has no isolation fields, and the child ran in/home/coderwith/home/coder/projstill onmain.The definition was deleted and the chats archived afterwards.