Repository navigation
feat(coderd/x/chatd): stop the workspaces of workspace subagents when their family is archived - #147
Conversation
…orktree summaries
…on-6b-archive-stops-workspace
… their family is archived
…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.
…on-6-workspace-mode # Conflicts: # coderd/x/chatd/ARCHITECTURE.md # coderd/x/chatd/fork_isolation_report.go
…agent-isolation-6b-archive-stops-workspace # Conflicts: # coderd/x/chatd/fork_isolation_workspace.go
… the stop_workspace tool
@codex review |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 034001080b
ℹ️ 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".
… removal A worktree grandchild of a workspace subagent lives in that subagent's workspace, so stopping the workspace first left its worktree behind. The cleanup now stops workspaces after it removes the worktrees, and skips a subagent whose chat is now bound to another workspace, which the stop tool would otherwise stop.
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! 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-6b-archive-stops-workspace # Conflicts: # coderd/x/chatd/fork_isolation_workspace_internal_test.go
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
|
…space stop in the pstack adapter (#154) * docs: map notify_user and the daily wake-up limits in the pstack adapter * docs: check the pstack adapter against main at d1bb658 * docs: re-pin pstack adapter cites that #115 and #136 moved * docs: re-pin pstack adapter cites that #136 moved * docs: say that a root archive stops the workspaces of workspace subagents * docs: re-pin pstack adapter cites that #147 moved * docs: qualify the wake-up limits, pause notices, inbox, and workspace autostop * docs: condition the archive cleanup of isolated subagents on the experiment * docs(docs/fork): qualify notification limits and the archive workspace stop * docs(docs/fork): qualify notify_user availability, limit, and silent drops
Part of #9. Builds on #144 (open), which spawns a subagent into its own workspace with
isolation: workspace. In #144, archiving the family leaves that workspace running, and it keeps using compute until someone stops it.With experiment
fork-subagent-isolationon, archiving a family now also stops the workspace of each workspace subagent. Worktree subagents already get their worktree removed after the archive commits (#138). After that removal, and after the notice of kept worktrees, the same background task now stops workspaces. A worktree grandchild of a workspace subagent lives in that subagent's workspace, so the worktree has to go first.chat_subagentsrow hasisolation = workspaceand aworkspace_id, and whose chat is still bound to that workspace, the task runs the existingstop_workspacetool as the chat owner. This is the same helper feat(coderd): spawn subagents into their own workspace with isolation workspace #144 uses when a spawn fails.With the experiment off, nothing changes.
Limits
Code
coderd/x/chatd/fork_isolation_cleanup.go: the workspace branch of the cleanup loop.scheduleArchivedWorktreeCleanupandcleanupArchivedWorktreesare renamed toscheduleArchivedSubagentCleanupandcleanupArchivedSubagents.coderd/x/chatd/fork_family_lock.go: the call site of the rename.coderd/x/chatd/ARCHITECTURE.md: a TODO for the stop.Tests
TestForkArchiveStopsSubagentWorkspaces(chatd, fake workspace stop on a real database, where a stop makes the agent unreachable):StopsRunningWorkspaces: a family with two workspace children and one shared child is archived. The running child's workspace is stopped. The child whose workspace is already stopped isn't stopped again, and neither is the shared child.AfterWorktreeRemoval: the worktree of a worktree grandchild inside a workspace child is removed before that workspace stops.SkipsReboundChild: a workspace child that was bound to the root's workspace stops nothing.Negative controls, each reverted after the run, each make a named case fail: skipping the stop, stopping without the tool (which also stops the already-stopped workspace), stopping during the worktree collection (
AfterWorktreeRemoval), and dropping the binding check (SkipsReboundChild).go vet,gofmtandgo test ./coderd/x/chatd/...pass.UAT
On the :3200 branch server at 0989048, with a real model and experiment
fork-subagent-isolationon, a root chat in workspaceuat3200-iso1spawned one child withisolation: workspace, into workspaceuat3200-docker-a6e2. The child'sexecuteprinted that hostname, andwait_agentreturned its report. The family was then archived. In the same second, the child's workspace got a stop build (initiator: the chat owner), and it was stopped 20 seconds later. The root's own workspace,uat3200-iso1, kept running.