[Bug]: Stale OMP sessions survive terminal close and keep eating memory (workers + Deno LSP)
Operating system
Unknown (reporter: @beebyboss on X). Likely macOS given Hermes cleanup tooling, but not confirmed.
Orca version
Unknown — reported 2026-07-17 on X.
Details
Summary
User reported that stale OMP (omp / oh-my-pi) sessions started in Orca kept running after their terminals were gone, some for ~2 days / up to 38 hours, and consumed enough memory that they had to kill the tree with Hermes.
OMP author (@_can1357) noted that the foreground omp process itself was still alive — so this is not only “detached child workers surviving parent death.” Worker daemons, eval workers, and Deno LSPs are expected children of a live OMP process; the Orca-side bug is that the owned agent PTY / foreground omp was not cleaned up when the terminal closed.
Source report
- Original: https://x.com/beebyboss/status/2078024006167384224
- Reply (OMP author): https://x.com/_can1357/status/2078025967440630110
What Hermes reported as killed (from the user post)
| Process class | Count / notes |
|---|---|
Stale omp sessions |
11 — orphaned from Wednesday terminals; some running ~38h |
| Worker daemon brokers + eval workers | 4 brokers + 35 eval workers — children spawned by those omp sessions |
| Deno LSP language servers | 7 — one per dead terminal (expected under live omp) |
| Already self-terminated | 1 ocuagent |
Process tree attribution (reporter / Hermes):
- Foreground processes were
omp --extension orca-agent-status.ts(Orca-managed OMP extension path). - All traced back to oh-my-pi / OMP coding sessions whose terminals were never properly cleaned up when closed.
- Hermes analysis: “Basically every omp invocation spawns a Deno LSP + worker pool, and none of them got cleaned up when the parent terminal closed.”
- OMP author: “the lsp et al. is normal, since the foreground process was also left alive… I can add an idle timeout, but bandaid. I don't quite know what happens when you 'background' it in Orca.”
Expected behavior (Orca “background” semantics)
Background in Orca is UI presentation, not process detachment.
When a terminal is created without focus (presentation: 'background' / no --focus):
- Orca still spawns a normal owned PTY with the agent command.
- It does not steal UI focus / may skip forced tab reveal.
- The process is fully live and addressable via terminal handles.
- It is not shell
bg/nohup/ daemonize.
On terminal close / kill, Orca is supposed to:
- Shut down the PTY (
SIGTERM, then process-group force kill after ~5s on POSIX). - For agent sessions (including
ompwhenlaunchAgentis set or the command is recognized), also run a descendant tree kill (ppid snapshot → SIGTERM → delayed SIGKILL) because agent CLIs spawn tool children in detached process groups that SIGHUP never reaches.
Relevant code:
- Background create:
src/main/runtime/orca-runtime.ts(createTerminal,resolveTerminalPresentation,shouldCreateInBackground) - CLI default background unless
--focus:src/cli/handlers/terminal.ts - Agent descendant kill policy:
src/main/providers/local-pty-provider.ts(ptyAgentSessionIds,shutdownTrackedPty) - Descendant sweep:
src/main/pty-descendant-termination.ts - PTY TTY process-group force kill:
src/main/pty/posix-pty-process-groups.ts - OMP is a first-class TUI agent:
src/shared/tui-agent-config.ts(omp)
Actual behavior
- Foreground
ompprocesses (with Orca’sorca-agent-statusextension) remained alive after terminals were gone. - Child worker pools + Deno LSPs stayed up under those parents and accumulated over days.
- User had to clean up outside Orca (Hermes).
Impact
- Unbounded memory growth from leaked agent sessions + LSP + worker pools.
- Especially painful when multiple OMP terminals are opened over days and closed without successful teardown.
- User-visible as “Orca is eating my RAM” even when no agent tab appears active.
Hypotheses to investigate (ordered)
-
Close path never ran
pty.kill/ provider shutdown for those tabs- UI tab close without kill ownership
- Headless / background-surface tabs that drop from graph without kill
- Runtime/CLI close targeting a handle that no longer maps to the live PTY
-
Daemon-owned PTYs outlived app/runtime tracking
- Related class: #7783 (Orca Helper / daemon keeps agent trees after UI/runtime reports not running)
- Once runtime is gone, normal
orca terminal *cannot clean them up (runtime_unavailable)
-
Kill ran but failed to land on the shell/omp
- Less likely for a still-attached foreground process given process-group SIGKILL, but possible if PID ownership was wrong, provider routing failed (
pty:kill/ daemon startup race — see comments around #7742 insrc/main/ipc/pty.ts), or the process was reparented off the PTY TTY
- Less likely for a still-attached foreground process given process-group SIGKILL, but possible if PID ownership was wrong, provider routing failed (
-
Session not agent-marked
- Only agent-marked PTYs get descendant sweep
- If user typed
ompin a plain shell tab without recognition, children can survive classic shell kill — still should not leave an attached foregroundompif the PTY root was force-killed
-
OMP-side reparenting of workers (secondary)
- Even with correct parent kill, double-forked / reparented workers can survive if they leave the ppid tree before snapshot
- OMP author already suggested idle timeout as a band-aid for that class
- Does not explain live foreground
ompafter terminal close
Related issues
| Issue | Relationship |
|---|---|
| #7783 | Same lifecycle class: managed agent trees survive after Orca UI/runtime is gone (macOS daemon Helper). This report is specifically OMP + memory + terminal-close / stale-for-days. |
| #9414 | Tracking for recognition-independent lifecycle safety; may cover unrecognized agents, but OMP is recognized. |
| #8459 | Resource Manager orphan false-positives — inverse problem (killing live sessions). Don’t conflate. |
| #9193 | Close/tab handle resolution gaps for floating PTYs. |
Reproduction checklist (needed)
We do not yet have a conclusive in-repo repro. Please capture:
- [ ] Orca version + OS
- [ ] How OMP was started: Agent button /
orca terminal create --command omp/ typed in shell / worktree startup - [ ] Focused vs background (
--focusor not) - [ ] Daemon on or off
- [ ] Exact close path: tab X, worktree remove, app quit, mobile close, etc.
- [ ] Whether Orca still listed the terminal before cleanup (
orca terminal list --jsonif runtime up) - [ ] Sample process tree while leaked (
ps/ Activity Monitor / Hermes dump), including PIDs of shell,omp, brokers, Deno LSP - [ ] Whether foreground
ompwas still parented under Orca’s login/zsh/PTY or had reparented to init
Suggested repro probes
# After starting OMP in Orca and closing the terminal tab:
pgrep -fl 'omp|deno|orca-agent-status'
orca status --json
orca terminal list --json # if runtime reachable
- Start OMP via Orca agent launch (so
orca-agent-statusextension is present). - Close the terminal tab normally.
- Immediately check whether
omp/ Deno LSP / worker processes remain. - Repeat with CLI background create (
orca terminal create --command 'omp …'without--focus) and with app quit.
Acceptance criteria
- Closing an Orca terminal that owns an OMP session terminates:
- the PTY shell
- the foreground
ompprocess - descendants still in the agent tree (workers / LSP) that are reachable via process-group or descendant snapshot
- After app quit (or with daemon keep-alive policy explicitly defined): either full tree is killed, or leftovers are visible and stoppable without manual process hunting.
- No multi-day accumulation of Orca-started
ompsessions after their terminals are closed.
Notes for OMP coordination
- Foreground leak = Orca responsibility.
- Idle timeout / self-cleanup for reparented workers + LSP when parent dies or TTY vanishes would still be a useful safety net on the OMP side (as @_can1357 suggested).
Same lifecycle class on Windows with Codex/Grok (Orca 1.4.188), not only OMP:
- 9 live Codex sessions → 27
tavily-mcpnode processes and 26 AnySearch/askecho python processes (one MCP interpreter tree per agent) - After closing tabs, copies remain (
cmd.exe /c tavily-mcp→ node, plus uv/python askecho).codex.execount drops; MCP often does not.
Acceptance from this issue (PTY + foreground agent + descendants) would cover that Windows MCP path too. Measurements: https://github.com/stablyai/orca/issues/16211
Lifecycle work now covers the two distinct paths:
- #20642 (merged) stops detached OMP tools on immediate local terminal close.
- #20645 (merged) covers the relay close path.
- #21629 covers app-quit cleanup for local fallback agent PTYs while preserving daemon-backed OMP sessions across a normal Orca quit. Explicit tab close remains the intentional teardown path.
I exercised the #21629 focused shutdown tests (76 passed), node typecheck, changed-code quality, and package builds. Its required CI is currently blocked by unrelated current-main failures: the anti-slop shapes naming gate and pane-title-update-global-scan-budget assertion. I am leaving this issue open until #21629 is merged and the full lifecycle gate is green.
Current-main fix is prepared as #21668. It targets local POSIX OMP PTY process-group cleanup during Orca app quit. Daemon-backed sessions remain alive across app quit; explicit tab/worktree closure still terminates the session. Focused lifecycle tests, node typecheck, and changed-file quality checks pass; required CI is running.
PR #21668 is merged (2e278426efa1). It force-cleans local POSIX OMP PTY process groups during app quit while preserving daemon-backed session survival. Focused lifecycle tests, node typecheck, full CI, packaging, and verify passed.
Fixed by #21668.