Skip to content

agentctl: stale-state session can't be peeked/resumed/stopped; orphaned wrapper survives #182

Description

@doink-kindo

Encountered while triaging a coding-agent run in a private workspace.

Symptom: agentctl list -a shows a 'running' opencode session. agentctl peek <id>, agentctl resume <id> ..., and agentctl stop <id> --force all return Session not found: <uuid>. The wrapper PID + child opencode process remain alive (had to kill -9).

Repro shape (sanitized):

  1. Launch agentctl launch opencode with a long-running prompt.
  2. After ~30+ min the agentctl state for the session apparently disappears (cause TBD — possibly a state-file cleanup race or interrupted write).
  3. list -a still reports the session as running (likely from the process table or stale registry).
  4. peek, resume, stop --force all fail with Session not found.
  5. agentctl launch --cwd <dir> is blocked by Directory in use by session <id>. Use --force to override. so the orphan also holds the directory lock.

Workaround: kill -9 the wrapper + child PIDs manually, then relaunch with --force.

Asks:

  • stop --force should kill PIDs by recorded PID even when state is missing — falling back to the cgroup/process table rather than only the state file.
  • list -a and the directory-lock check should agree on session existence; if one source says "running" and the other can't find the state, the inconsistency should be surfaced rather than silently blocking ops.
  • A agentctl reconcile or agentctl prune --orphans command would help.

Encountered on agentctl version: 1.9.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions