Repository navigation
feat(coderd): spawn subagents into their own workspace with isolation workspace - #144
Conversation
…orktree summaries
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bb356f74a1
ℹ️ 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".
…m in the background A created workspace whose agent is missing or not ready, or whose startup scripts did not finish, now fails the spawn. A failed spawn stops the child's workspace with the stop_workspace tool, in the background, so the stop waits for the create build instead of failing against it.
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 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". |
…on-6-workspace-mode # Conflicts: # coderd/x/chatd/ARCHITECTURE.md # coderd/x/chatd/fork_isolation_report.go
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01aa038a26
ℹ️ 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".
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01aa038a26
ℹ️ 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".
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
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. Builds on #141 (merged), which adds the
wait_agentreport for worktree children. A worktree child (#108, #135) shares its parent's workspace, so it shares its CPU, memory, ports and running processes. Some tasks need a machine of their own.With experiment
fork-subagent-isolationon,spawn_agentnow acceptsisolation: workspace. The child gets its own new workspace, built from the template of the parent's workspace with the parameters of the parent's latest build. The spawn waits until the build succeeds, the agent is ready and its startup scripts finish, so the child's first turn can use the workspace.createSubagentChatWithIDcreates the childwaiting, with no workspace and without its prompt, and recordsisolation = workspaceon itschat_subagentsrow in the same transaction as before.create_workspacetool for the child. That tool names the workspace, creates it as the chat owner, binds it to the child, and waits for the build and the agent. Its result counts as success only if it reportscreated: trueand reports noagent_statusorstartup_scriptsproblem.workspace_idon the child'schat_subagentsrow and sends the child its prompt, so the first turn starts there.If step 2 or 3 fails, the child is archived. Any workspace it got is stopped in the background with the
stop_workspacetool, which first waits for an active build (best effort). The spawn then returns the error, for examplecreate the child's workspace: workspace quota exceeded.spawn_agentandwait_agentreportisolation: workspaceand the child'sworkspace_name, orworkspace_errorwhen the name cannot be read.repo_pathandbase_branchare refused withisolation: workspace. With the experiment off, nothing changes.Limits
spawn_agentslow.isolation: workspace.waitingand accepts a message sent to it directly, which would run before its prompt.UserPromptSubmithook names the parent's workspace, not the child's.Size: 293 added production lines (218 in
fork_isolation_workspace.go) and 272 test lines.Code
coderd/x/chatd/fork_isolation_workspace.go: the workspace source, the deferred prompt,startSubagentWorkspaceanddiscardSubagent, and the workspace name for tool results.coderd/x/chatd/fork_subagents.go: theisolation: workspacebranch ofcreateSubagentChatWithID.coderd/x/chatd/fork_isolation.go,fork_isolation_report.go: the new enum value and the result fields.coderd/database/forkdb/queries/chat_subagents.sql:UpdateChatSubagentWorkspaceID, generated withforkdb/generate.sh, with dbauthz (update on the chat) and dbmetrics wrappers.coderd/x/chatd/ARCHITECTURE.md: a TODO for the mode.Tests
TestForkSpawnIsolationWorkspace(chatd, fake workspace creation on a real database): the child's workspace is created from the parent's template with the parent's build parameter, it is bound and recorded, the child's only user message is the prompt, andspawn_agentandwait_agentreport the workspace name. A failed creation archives the child and stops nothing; a failed build, a workspace without an agent, or failed startup scripts archive the child and stop its workspace in the background; a parent without a workspace is refused before any child exists.TestForkQuerier/UpdateChatSubagentWorkspaceID: dbauthz checks update on the chat.TestForkSpawnIsolationErrors: the enum message, andrepo_pathwithisolation: workspace.Negative controls, each reverted after the run, each make a named test fail: dropping the build parameters, skipping the archive on failure, skipping the stop, recording no workspace, skipping the prompt, ignoring
created: false, ignoringagent_status(NoAgent fails), and ignoringstartup_scripts(StartupScriptsFail fails).UAT
On the :3200 branch server and workspace agent at bb356f7, with a real model, a root chat in workspace
uat3200-iso1spawned one child withisolation: workspace. The spawn took about 4 seconds and returnedworkspace_name: uat3200-docker-1623. The child'sexecuteprinted that hostname andCODER_WORKSPACE_NAME, andwait_agentreported the same workspace name.Checked outside the model: the new workspace is owned by the chat owner and uses the parent's template at its active version. Its start build succeeded and its agent was ready. The child chat is bound to it, its
chat_subagentsrow hasisolation = workspaceand thatworkspace_id, and the child's only user message is the prompt, created after the agent was ready. Archiving the family left the child's workspace running, as listed under Limits. The failure paths were not run on the server, because the template has no parameter that can make a build fail. The tests cover them. The readiness checks and the background stop came after the UAT, at b60c5ef, and are covered by tests and negative controls.I ran the happy path again on the :3200 branch server at 0989048 (#147, which contains this PR's head 01aa038). It spawned one child into workspace
uat3200-docker-a6e2, owned by the chat owner, using the parent's template. Its start build succeeded and its agent was ready. The child'sexecuteprinted that hostname, andwait_agentreturned the report withisolation: workspaceand that workspace name.