Skip to content

agentctl stop: session lookup mismatch — running session reports 'Session not found' #187

Description

@doink-kindo

Discovered 2026-05-27 during a Kimi-mid-run cancel.

Repro

  1. agentctl launch opencode --worktree X --branch Y -p "..." returns short ID cb6c8091.
  2. agentctl list -a shows cb6c8091 running.
  3. agentctl status cb6c8091 returns full status (running, PID, model).
  4. agentctl stop cb6c8091 returns Session not found: cb6c8091-20e6-421c-bf51-a4b6fa2ab604.
  5. agentctl stop cb6c8091 --force same error.

In both cases the resolver expands cb6c8091 to a full UUID cb6c8091-20e6-421c-bf51-a4b6fa2ab604 (which matches the wrapper script path under ~/.agentctl/opencode-sessions/wrapper-<uuid>.sh). status finds it; stop does not.

Workaround

Kill via PID tree: pkill -P <wrapper-pid>; kill -TERM <wrapper-pid>. Local state stays stale (status still reports running) until the next list refresh.

Probable cause

The stop path likely looks up sessions in a different store (or with stricter status filter) than status/list. Possibly only finds sessions in a specific lifecycle phase. Worth checking the session-state-machine glue in opencode adapter.

Impact

Medium. Forces PID-kill fallback, leaves stale local state, breaks the documented agentctl stop <id> UX. The --force flag does not bypass the lookup, suggesting this is a registry/store consistency bug rather than a permission/state-guard issue.

Environment

  • macOS 25.4 arm64
  • agentctl version: agentctl --version output (TBD — fill in if reproducing)
  • adapter: opencode
  • model: ohm/moonshotai/Kimi-K2.6

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