Repository navigation
feat(coderd/x/chatd): archive one child subtree with archive_agent - #281
Conversation
@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: 3a446d2c78
ℹ️ 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: 72e229144f
ℹ️ 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".
Merged main after #278 and fixed the unbilled tool finding. @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". |
Merged as Gates checked on head
Not exercised: a live chat calling |
Closes #249
What changed
With
fork-nested-subagentson, a chat that hasinterrupt_agentalso getsarchive_agent. It archives one direct child and all of that child's descendants for good, so a parent can retire a child subtree without archiving the root.archive_agenttakes the child'schat_id. Any chat that is not a direct child of the caller is refused withchat_id must be a direct child of this chat.settleChatsForArchive, split out offorkArchiveActiveFamily).FOR NO KEY UPDATE, then the child's descendants leaves first, then the child (lockSubtreeForArchive, split out oflockFamilyForArchive), and appliesSetArchived(true)to each member not archived yet. A busy member fails the whole call and archives nothing. Wake-ups of archived chats are canceled withfork-chat-wakeups, as in a family archive.fork-subagent-isolationon, it reuses the root archive cleanup:cleanupArchivedSubagentsis split intoremoveArchivedSubagentWorktreesandstopArchivedSubagentWorkspaces. The worktree removal runs before the tool returns and lists kept worktrees inkept_worktrees. Workspace stops run in the background. The root archive path still posts its notice.list_agentsand the live subagent count, so a family at its live limit can spawn again. Only archiving and then unarchiving the root brings them back.archive_agentis inunbilledSubagentToolNames, like the other subagent tools, so its wait is not billed.archive_agentis part of theTaskalias in custom agent tool policies.docs/fork/pstack-adapter.mdno longer says only a root archive cleans up, andcoderd/x/chatd/ARCHITECTURE.mddescribes the subtree archive.#278 (list descendants) merged first. This branch merges
mainafter it, with a merge commit.Tests
cd coderd/x/chatd && flock ~/.fork-go.lock go test -count=1 -run 'TestForkArchiveAgent' -v .passes:ArchivesOneChildSubtree: root with two worktree children (one with a worktree grandchild) archives one child. The child and grandchild worktrees and branches are removed, the sibling and root stay unarchived,list_agentslists only the sibling, and no root notice is posted.ReportsKeptWorktree: a dirty worktree is kept and reported with the agent's reason. A later root archive tries it again and lists it in the root notice.StopsChildWorkspace: only the archived child's workspace is stopped.OnlyDirectChildren: grandchild, sibling, parent, self and unknown IDs are refused. A child archives its own grandchild, and a later archive of the child skips it. Archiving and then unarchiving the root brings every chat back.ExperimentOff: noarchive_agentwithoutfork-nested-subagents.TestForkArchiveAgentFreesLiveLimit: withmax_live_per_family1, archiving a running child lets a second spawn succeed, andmessage_agentto the archived child fails.TestUnbilledSubagentToolNamesMatchCatalogpasses witharchive_agentin the unbilled set.main(with feat(coderd/x/chatd): list a chat's descendants with list_agents #278):TestForkArchiveAgent|TestForkListAgentsDescendants|TestUnbilledSubagentToolNamesMatchCatalog|TestForkArchiveWorktreeCleanup|TestForkArchiveStopsSubagentWorkspaces|TestNestedArchiveActiveFamily|TestNestedInterruptCascade|TestCustomAgentToolPolicy|TestForkSetFamilyArchived|TestNestedSubagentpass, andgo vet ./coderd/x/chatd/is clean.fork_tools.goremoved, 4 of these fail (ExperimentOff passes, as expected).TestForkArchiveWorktreeCleanup|TestForkArchiveStopsSubagentWorkspaces|TestNestedArchiveActiveFamily|TestNestedInterruptCascade|Lock|TestCustomAgent|ToolPolicy|TestNestedSubagentandTestCustomAgentToolPolicy|TestForkSetFamilyArchived|TestAutoArchive|TestArchive|TestUnarchivepass.golangci-lint run --fix=false ./coderd/x/chatd/reports nothing in changed files.make lint/emdash,make lint/docs-html,make lint/architecturepass.markdownlint-cli2is clean onpstack-adapter.md;ARCHITECTURE.mdhas the same 10 findings asmain.Not verified