flying_crp (X, 2026-10-31): when one agent hands work to another and then
interrupts it from the command line, the delegated session hangs in the
Agent Office as abnormal and can't be cleaned up; it only goes once the
session is deleted in magpie.
The cause: a killed agent writes no end of turn. Reproduced in a sandbox
HOME with the real CLIs:
- Codex 0.165 under SIGTERM or SIGKILL: the rollout ends at the
function_call (on SIGINT it writes turn_aborted, which was fine).
- Claude Code 2.1.314 `claude -p` under SIGTERM: a tool_result
("Exit code 137") and no end_turn, and it removes its
sessions/<pid>.json. Under SIGKILL: the file ends at tool_use, and the
pid file stays with a dead pid.
The office read each file as at work, then "error · stuck" once quiet for
ten minutes, until hideAfter (6h, or never; a waiting session never
leaves). The page had no way to take one out.
The fix:
- lib/scan.mjs: for a source with a process folder (Claude Code's
<config>/sessions, also Qoder, WorkBuddy and CodeBuddy), a session
quiet mid-turn for 10s with no live process named in that folder is
read as aborted ("stopped"). A folder that can't be read, a
half-written file, or one that has never held a pid file means
unknown, and nothing changes. A pid file from another pidDomain (WSL)
counts as alive.
- page: Clear (清除) in the panel of any agent not at work (stuck,
error, stopped, done, waiting) hides it until its session moves again.
It is kept in the page's options as {key: at}, pruned to sessions
live.js still has. This covers Codex and every agent with no process
registry.
Run:
- On mote (mote-run): bun test in packages/agent-office gives 54 pass,
0 fail. bun scripts/check.mjs exits 0.
- killed.test.mjs uses the real killed files (test/killed, trimmed and
with paths replaced). With the old scan.mjs, 3 tests fail. With the old
model.js, 2 fail.
- End to end: the real office.hooks.mjs over a sandbox HOME holding the
killed Claude and Codex files and a live lead pid file. live.js had
claude "aborted" and codex "tool". Then the real page in list mode, zh,
at widths 1100 and 420: the Codex row shows 已 N 分 没有动静, its
panel shows 清除, clicking it removes the row, and options.set gets
cleared. Chromium ran on mote. WebKit ran on the Linux box (wsl-run),
because WebKit on mote didn't launch within 180s while ~108 WebKit
processes from other sessions were running. Screenshots were checked
at both widths.
Not tried:
- A Codex liveness signal: its thread-writer-locks are flock-only files,
which Node can't check. Codex relies on Clear.
- Windows: the pidDomain value and process.kill(pid, 0) there.
- Whether Qoder, WorkBuddy or CodeBuddy write pid files at all. Without
them, nothing changes for those agents.
- Gemini, Qwen, dsh and pi killed mid-turn: they have no registry and
rely on Clear.
- The page inside the real magpie window, and WebKitGTK.