agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

[Bug]: ao session kill fails permanently when the workspace is already gone, and cleanup cannot recover it

Open ryanlawyer opened this issue 2 months ago • 0 comments

Summary

A session whose worktree has already been removed can never be terminated. ao session kill fails with INTERNAL_ERROR, which means the session's terminated flag is never set — and ao session cleanup only processes terminated sessions, so it skips it forever. The two code paths disagree about whether a missing workspace is an error, and the session is stuck visible in the sidebar permanently.

Reproduction

  1. Have a worker session with a git worktree.
  2. Kill it once. In my case the first kill returned INTERNAL_ERROR but did remove the worktree and set status: exited.
  3. Retry ao session kill <id> — it fails every time thereafter:
Internal server error (INTERNAL_ERROR) [request EID-.../...]
  1. ao session get <id> shows the contradictory state:
status: exited
activity: exited
terminated: false
  1. ao session cleanup --project <project> never offers it. Other sessions in the same state are offered and report Already gone: <id> (workspace was missing; nothing reclaimed) — so cleanup handles a missing workspace gracefully.

Expected

Either:

  • kill should treat an already-missing workspace as success (idempotent) and set terminated, or
  • cleanup should be able to reclaim sessions that are exited but not terminated.

Right now neither is true, so the session is unreachable by any path.

Actual

Permanently stuck. The only observable difference between this session and its siblings that cleaned up fine is that its terminated flag is false.

Notes

  • Reproducible on Windows 11, ao daemon healthy (ao doctor all green), the rest of the session lifecycle working normally.
  • ao session cleanup output confirms the graceful path exists — Already gone: ... (workspace was missing; nothing reclaimed) — it just isn't reachable for a session that never got marked terminated.
  • I have not read the kill path's source, so the above is observed behavior rather than a diagnosed root cause. The asymmetry between the two paths' handling of a missing workspace looks like the likely culprit.

ryanlawyer avatar Sep 15 '26 21:09 ryanlawyer