Skip to content

[Feature]: CLI PTY / resource health for headless serve (agent self-management) #10609

Open

Description

@LesleyMurfin

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):

  1. Extend orca serve stats --json with a nested pty / resources object, and/or
  2. Enrich orca terminal list / orca worktree ps with capacity/ownership/age fields, and/or
  3. 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

Activity

  1. LesleyMurfin commented on Jul 25, 2026

    @LesleyMurfin
    ContributorAuthor

    Depends on / complements #10608 (serve stats substrate). CLI slice of #9840 — does not close it.

  2. LesleyMurfin commented on Jul 25, 2026

    @LesleyMurfin
    ContributorAuthor

    Sequencing: serve stats is in draft PR #10612 (closes #10608). This issue remains the follow-on CLI PTY/resource-health slice after that lands.

  3. added
    enhancement
    on Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions