Repository navigation
feat: summarize isolated subagent worktrees in wait_agent - #141
Conversation
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: 61c288ebd0
ℹ️ 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".
…orktree summaries
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f68de5628f
ℹ️ 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: a6235c57c5
ℹ️ 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. You're on a roll. 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 #108 and #135 (both merged), which give a
spawn_agentchild withisolation: worktreeits own git worktree and branch. Until now the parent had to inspect that branch itself to learn what the child did.With experiment
fork-subagent-isolationon,wait_agenton a worktree child now adds:isolation,branchandworktree_pathfrom the child'schat_subagentsrow, asspawn_agentalready returns them.diff_summary:commits,files_changed,insertions,deletionsanduncommitted_changes, read from the child's workspace agent.diff_summary_errorinstead, with the agent's reason, when the agent cannot be reached or refuses, for examplesummarize worktree: worktree /x does not existor a dial failure.A wait that times out reports the first three fields but skips the summary, since the child may still be changing its worktree. Shared children, and results that are errors, are unchanged. With the experiment off, nothing changes.
The summary is one request per
wait_agentcall, bounded at 30 seconds with the dial capped at the chatd dial timeout. There are no retries or fallbacks.What the numbers mean
commits: commits on the worktree's HEAD that are on no other branch or remote, the same set the delete endpoint (feat: add worktree isolation to spawn_agent #108) refuses to drop.files_changed,insertions,deletions:git diff --numstatfrom the parent of the oldest such commit (or HEAD without one, or the empty tree when that commit is a root) to the working tree. Uncommitted edits to tracked files count; untracked files do not. Binary files count as changed with no lines. Submodule changes count even when the repository's config ignores them, as in the status count.--numstatis used because--shortstatoutput is localized.uncommitted_changes: paths ingit status --porcelain, untracked files included.The agent answers 409 when the worktree is not on the requested branch, since commits on another branch are not this branch's work.
Size: about 360 added production lines, 47 of them moved out of delete, and 255 test lines.
Code
agent/agentgit/fork_worktree_summary.go:POST /api/v0/git/worktrees/summary.agent/agentgit/fork_worktrees.go: the linked-worktree path checks and the on-branch check of delete move intocheckLinkedWorktreeandonBranch, which summary also uses. Delete's responses are unchanged.codersdk/workspacesdk/fork_worktrees.go:ForkWorktreeSummary, its request, andForkWorktreeSummaryConn, a separate interface so older connection types still satisfyForkWorktreeConn.coderd/x/chatd/fork_isolation_report.go: wrapswait_agent, enabled fromappendForkTools.coderd/x/chatd/ARCHITECTURE.md: a TODO for the report.Tests
TestForkWorktreeSummary(agent, real git): a clean worktree is all zeros; two commits plus an uncommitted edit, a binary file and an untracked file give the expected counts; commits that another branch holds count as zero; a root commit diffs against the empty tree.TestForkWorktreeSummarySubmoduleIgnoredByConfig: a committed submodule bump counts as one changed file whensubmodule.sub.ignoreisall.TestForkWorktreeSummaryRejects: a removed worktree is 404 and a worktree on another branch is 409.TestForkIsolationWaitAgentReport(chatd, fake agent connection): a worktree child gets the fields and the summary for its stored path and branch; an agent error becomesdiff_summary_errorwith the agent's message; a wait that times out on a running child gets the fields but no summary request; a shared child that has achat_subagentsrow gets nothing and no agent call.Negative controls, each reverted after the run, each make a named test fail: dropping the empty-tree fallback, dropping the branch
--exclude, diffing to HEAD instead of the working tree, dropping the on-branch check, dropping--ignore-submodules=nonefrom the diff, not wiring the wrapper, returning the raw SDK error, and dropping the isolation check, and requesting the summary on a timed-out wait.UAT
On the :3200 branch server and workspace agent at 61c288e, with a real model, a root chat spawned a worktree child and a shared child. The worktree child committed a two-line file and left an untracked file.
wait_agenton it returned its branch and worktree path anddiff_summary{commits: 1, files_changed: 1, insertions: 2, deletions: 0, uncommitted_changes: 1}, which matchesgit rev-list,git diff --numstatandgit statusrun in that worktree.wait_agenton the shared child returned none of the new fields. The main checkout stayed onmainand clean. The later fixes (a diff flag for submodules, and skipping the summary on a timed-out wait) are covered by their tests.