Repository navigation
🤖 fix(tasks): list a removed sub-agent's leftover processes in task_remove - #8214
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)ℹ️ 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 |
🟢 e2e stories (Haiku): 14 passed21 agent steps · 6 replayed from cache · 15 model calls · 47.5k tokens (23% cached) All 14 tests in 9 files
e2e 0.20.0 · 1m 17s · web · run artifacts 🟢 e2e Electron stories (Haiku): 3 passed3 agent steps · 3 model calls · 7.9k tokens (22% cached) All 3 tests in 3 files
e2e 0.20.0 · 19.6s · electron · run artifacts 🟢 e2e agent repros (Haiku): no tests selectedSpend: $0.00 of the $1.00 cap (proxy ledger) e2e 0.20.0 · 6.5s · 2 targets (web, phone) · run artifacts |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 225a123303
ℹ️ 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".
There was a problem hiding this comment.
🛡️ Codex Security Review · Automatically triggered
Here are some automated security review suggestions for this pull request.
Reviewed commit: 225a123303
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
|
@codex review |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93bdcea722
ℹ️ 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 Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b65a3387c
ℹ️ 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 Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a84b0e532f
ℹ️ 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".
|
Pausing the review loop on this PR. It is not converging. The Codex rounds on the process sweep have found new gaps in the same area every time: 4, then 3, then 2, and now 3 new findings. Each one is about whether the
Following the repo's PR rules, I am not adding more mechanism until the owner picks a direction:
Fixed and pushed so far: argv no longer reported, output capped, warnings when the check is unavailable, the no-metadata path, the secret override of the marker, rescan after SIGTERM, and a missing Generated with |
|
@codex review The owner narrowed this PR from stopping leftover processes to listing them (see the PR body), so please review the new head as a whole. |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2df7764662
ℹ️ 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. Can't wait for the next one! 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". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
PASS+NOTES Independent verifier. Parent Setup per run: a finished background task that left
Checkout deleted and config row gone in every case. No result holds Notes
Generated with |
Two real-stack repros (TaskService, WorkspaceService, BackgroundProcessManager, a worktree checkout, the real bash tool with a turn's XUM_ env) of task_remove removing a sub-agent while processes it started keep running in its deleted checkout, with nothing in the removal result: - a daemon that a finished run_in_background task left in its process group (`sleep 300 & ...`): the task reads "exited", so removal's cleanup skips its group kill; - a job a foreground bash call detached with `setsid -f`: Xum never tracked it. Each wraps its target assertion in expectReproFailure, so it passes while the bug exists and fails once it is fixed.
task_remove and the user's sub-agent removal left processes the sub-agent started running in its deleted checkout, and said nothing about them. Removal's background cleanup stops only the process groups of running tasks, so a daemon a finished task left in its group, a `setsid -f` job and a grandchild that left its task's group all survived. A sub-agent removal now sweeps them after that cleanup and before the checkout deletion: every bash call of a workspace runs with XUM_WORKSPACE_ID=<id>, so a script on the workspace's runtime SIGTERMs (then SIGKILLs) each process whose /proc environ holds that exact entry, sparing itself and its ancestors (workspaceProcessSweep.ts, as remoteExecMarker.ts does for remote execs). - task_remove results gain `processes` (pid, command cut to 200 chars, the bash:<id> task whose group it was in, outcome stopped|still_running) and `processCheck: "unavailable"` when the host has no /proc or the sweep did not finish. - The user's removal adds one warning per process still running and one summary warning for those it stopped. - A root workspace's removal (and its descendant cascade) is unchanged. The repro tests from the previous commit now assert the fixed behavior. Follow-ups: task_stop of a bash task still leaves grandchildren that left its process group, and archive does not sweep.
parseWorkspaceProcessSweep was a new function at CC 10 (limit 8). Its per-line parse and the removed-process mapping are now their own functions; behavior is unchanged (workspaceProcessSweep.test.ts).
The sweep reported /proc/<pid>/cmdline, and argv can hold expanded project secrets (`server --token "$TOKEN"`) that then reach the model and disk. Report /proc/<pid>/comm instead, read with a builtin, and rename RemovedProcess.command to name.
With hundreds of leftover processes the sweep printed a row each and the whole list reached the model. The script still signals every match but lists at most TASK_REMOVE_MAX_LISTED_PROCESSES, prints an O <count> line for the rest, and the result reports processesOmitted (the user's removal adds one warning for them). The exec also gets a 64 KiB output cap as a backstop; a cut output loses DONE and reads unavailable.
removeSubagentForUser turned the swept processes into warnings but ignored processCheck: "unavailable", so on a host without /proc (macOS) or after a failed sweep the UI showed a clean removal. Add one warning for that case.
When getWorkspaceMetadata() fails, removal deletes the row on the phantom path but skipped the background cleanup and the sweep, so a sub-agent removal read clean. Run the background cleanup there too (it needs only the id; session disposal covers only a live session that did not keep its processes) and, with no runtime to sweep with, return processCheck: "unavailable".
The phantom path builds no runtime, so it passes no workspace path; the optional chain grew the function's CC past its CRAP floor.
Prettier wraps the removeSubagentForUser call.
Removing a sub-agent finds its leftover processes by their XUM_WORKSPACE_ID entry, so a secret of that name hid them and the removal reported none. Reserve the name the way the scratch-dir names are reserved. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
A daemon that restarts its worker from its SIGTERM handler starts a child after the sweep's scan, so the child never got SIGKILL and the removal did not list it. Scan /proc again after the SIGTERM wait, as buildMarkerKillScript does, and stop and list the new matches too. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
…g them
Sub-agent removal stops only Xum's tracked background tasks again, as on
main. Afterwards, before the checkout is deleted, it lists the pids that
still carry the sub-agent's exact XUM_WORKSPACE_ID entry (the check itself
and its ancestors excluded) and sends no signal: the entry is not proof
enough to kill, since two Xum installations can share a legacy workspace ID.
Each entry is { pid, taskId? }, with no name: a process can write anything
to its own /proc/<pid>/comm. /proc/<pid>/stat is read whole, so a name that
imitates stat fields cannot shift the process group used for taskId.
The result keeps processesOmitted and processCheck: "unavailable" and adds
processNote, which says the processes are still running and were not
stopped. The user's removal warns once with the count and pids, and once
when the check was unavailable. A removal without metadata no longer runs
the background cleanup that main does not run there.
---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
--- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
2df7764 to
674f247
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 674f247220
ℹ️ 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. Breezy! 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". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
PASS Independent re-verification of the delta 674f247..5727a05 at head 5727a05 (I did not write this code). Parent and head ran in detached scratch worktrees on Linux, Docker 27.5.1, Bun 1.4.3. What I ran, parent vs head
Notes
Generated with |
Why
task_removeleft a removed sub-agent's daemons running in its deleted checkout, with no owner and no mention in the result. Removal stopped only background tasks that were still running, so these survived: a daemon a finished task left in its process group (server &), a job a call detached withsetsid -f, and a grandchild that left its task's group.What changed
src/node/runtime/leftoverProcesses.ts: every bash call runs withXUM_WORKSPACE_ID=<id>, and descendants inherit it. After removal's existing background-task cleanup and before the checkout is deleted,listLeftoverProcesseslists each process whose/proc/<pid>/environholds that exact entry, skipping itself and its ancestors. It sends no signal.task_removeresult gainsprocesses({ pid, taskId? }, capped atTASK_REMOVE_MAX_LISTED_PROCESSES, plusprocessesOmitted),processNote(they are still running and were not stopped), andprocessCheck: "unavailable"when there is no/procorgrep, the check was cut off, or removal had no workspace metadata. The user's removal adds one warning with the count and pids, and one when the check was unavailable.mergeSecretsOverXumEnvrefuses a project secret namedXUM_WORKSPACE_ID, so a secret cannot hide processes from the list.Scope
Only sub-agent removal lists; removing a root workspace is unchanged. What gets stopped is exactly what main stops.
Tradeoffs
An earlier revision killed the listed processes. Four Codex rounds kept finding ways the kill could hit the wrong process (two installations sharing a legacy workspace ID) or report unsafe data (argv, a rewritable
comm), so the owner chose listing: a wrong match is now one extra pid in the list. The list reports no name or command, only pids and the owningbash:task. A process that clears its environment (env -i), or one started throughWorkspaceService.executeBash(which runs without the marker), is not listed; macOS and multi-project devcontainer sub-agents reportunavailable.Blast Radius
The result and warnings of sub-agent removal on Linux hosts and remote Linux runtimes, and the env of bash calls whose project defines a secret named
XUM_WORKSPACE_ID.Verification
taskService.removalProcessesRepro.test.tsstarts real processes through the real bash tool: a finished task's daemon and asetsid -fjob are listed by pid (the daemon with its task ID) and are still alive after removal.leftoverProcesses.test.tscovers the self, ancestor and prefix-ID exclusions, the cap, a host withoutgrep, and a process name crafted to shift/proc/<pid>/statfields.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$39.98(the whole three-PR stack)