← Back to PRs

#13284: fix(commands): /stop now kills orphaned exec processes

by thebtf open 2026-02-10 08:47 View on GitHub →
agents size: M
## Summary - `/stop` previously only aborted the embedded agent run (`abortEmbeddedPiRun`) but left spawned exec/bash child processes running, causing resource leaks - Now `handleStopCommand` also iterates over `listRunningSessions()`, matches by `sessionKey`, and calls `killSession()` on each orphaned process ## Test plan - [x] New test: `commands-session.stop-process-kill.test.ts` - [ ] CI <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR extends `/stop` handling so it not only aborts the embedded Pi run but also enumerates registered exec/bash sessions and calls `killSession()` for those matching the target `sessionKey`, addressing orphaned child processes. It also adds compaction improvements in the embedded runner: a configurable timeout for `session.compact()`, optional compaction model override, and forcing `reasoning: false` during compaction to avoid SDK summary calls triggering extended thinking. Tests were added/updated to cover compaction behavior and the new `/stop` process-kill behavior, and a small behavior tweak avoids emitting reset notifications into group chats. Key integration points are `src/auto-reply/reply/commands-session.ts` (command handling), the process registry/kill utilities in `src/agents/*`, and compaction logic in `src/agents/pi-embedded-runner/compact.ts` backed by new config schema fields under `agents.defaults.compaction`. <h3>Confidence Score: 3/5</h3> - This PR has valuable fixes but includes a couple of behavior gaps that can break expected cleanup and compaction tool configuration. - The `/stop` change relies on `listRunningSessions()`, which only returns backgrounded sessions, so some orphaned/foreground exec processes may remain. Separately, compaction’s model override is applied to model resolution, but downstream tool construction/sanitization still uses the primary provider/model IDs, so compaction runs can end up with tool policy/settings mismatched to the effective compaction model. - src/auto-reply/reply/commands-session.ts, src/agents/pi-embedded-runner/compact.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment --> --- ## Validation - [x] `pnpm build` — passes - [x] `pnpm check` — passes - [x] `pnpm test` — new test in commands-session.stop-process-kill.test.ts ## Contribution checklist - [x] **Focused scope**: /stop command now kills orphaned exec processes - [x] **What + why**: described above - [x] **AI-assisted**: Yes, Claude Code was used for implementation. Testing level: lightly tested (1 new test + manual)

Most Similar PRs