Repository navigation
Description
Problem or use case
Headless multi-host / long-running serve setups can exhaust OS PTY capacity (e.g. macOS opaque posix_spawnp failed) when stale shells, detached sessions, or obsolete relays hold PTYs. Operators and autonomous agents on serve hosts need capacity, ownership, and headroom signals before spawn fails.
#9840 asks for Resource Manager PTY health (capacity, process-backed PTYs, relay-owned vs others, visible vs detached, warn/critical, cleanup). Comments there also ask for a CLI surface for Serves so agents can self-manage resources without the desktop Resource Manager.
Serve occupancy alone (orca serve stats — #10608) is not enough: knowing terminals: N does not answer “11 of 511 PTY slots remaining; 20 owned by this Orca relay.”
Short summary: expose PTY (and related) health for headless serve via CLI/--json so agents and scripts can gate spawns; CLI slice of #9840, not a replacement for Resource Manager UI.
Proposed solution
Minimum useful CLI output (parseable with --json) for a selected serve/runtime:
- System PTY capacity and remaining headroom (where the OS allows)
- Active process-backed PTYs
- PTYs owned by the current Orca relay vs others / obsolete relays (when detectable)
- Visible vs detached (or equivalent lifecycle state)
- Optional warn / critical thresholds before exhaustion
Example operator-facing line (from #9840): Wheeljack has 11 of 511 PTY slots remaining; 20 are owned by Orca.
Surface options (decide in PR design; not fixed here):
- Extend
orca serve stats --jsonwith a nestedpty/resourcesobject, and/or - Enrich
orca terminal list/orca worktree pswith capacity/ownership/age fields, and/or - A focused subcommand if the payload outgrows stats.
Prefer reusing relay inventory from #9820 / #9819 (pty.listProcesses + paneKey + ageMs) rather than reinventing the data layer.
Sequencing: land #10608 (serve stats occupancy snapshot) first as diagnostic substrate; implement this as a second PR.
Non-goals for the first PR on this issue: full Resource Manager UI (#9840), aggressive auto-cleanup as the primary deliverable (coordinate with #9819 / #9820 / #10562; report candidates first), host CPU/RAM metrics (possible sibling later).
Alternatives or additional context
- [Feature] Feature request: PTY health monitoring in Resource Manager #9840 — product request for Resource Manager PTY health + cleanup; stays open for UI. This issue is the CLI-first slice (FireSly + dcieslak comments on [Feature] Feature request: PTY health monitoring in Resource Manager #9840).
- [Feature]:
orca serve stats [--json]— live headless-serve runtime stats #10608 / PR feat(cli): orca serve stats [--json] — live headless-serve runtime stats #10612 — serve live counts (agents/tasks/terminals/worktrees); complementary, does not solve PTY capacity/ownership. - SSH relay leaks orphaned PTY sessions until "Maximum number of PTY sessions reached (50)" #9819 / #9820 — orphan relay PTY reaping + listProcesses enrichment (data layer to build on).
- [Bug]: Externally deleted worktrees (git worktree remove outside Orca) strand their terminal/agent processes — reconcile paths run no teardown #10562 — stale sessions after external worktree delete (cleanup path).
- Existing CLI:
orca worktree ps/orca terminal listare natural homes for capacity/ownership/detached-state if not nested underserve stats.
Activity
LesleyMurfin commentedon Jul 25, 2026
Depends on / complements #10608 (serve stats substrate). CLI slice of #9840 — does not close it.
LesleyMurfin commentedon Jul 25, 2026
Sequencing: serve stats is in draft PR #10612 (closes #10608). This issue remains the follow-on CLI PTY/resource-health slice after that lands.