agent-orchestrator
agent-orchestrator copied to clipboard
[Bug]: ao session kill fails permanently when the workspace is already gone, and cleanup cannot recover it
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
- Have a worker session with a git worktree.
- Kill it once. In my case the first kill returned
INTERNAL_ERRORbut did remove the worktree and setstatus: exited. - Retry
ao session kill <id>— it fails every time thereafter:
Internal server error (INTERNAL_ERROR) [request EID-.../...]
ao session get <id>shows the contradictory state:
status: exited
activity: exited
terminated: false
ao session cleanup --project <project>never offers it. Other sessions in the same state are offered and reportAlready gone: <id> (workspace was missing; nothing reclaimed)— so cleanup handles a missing workspace gracefully.
Expected
Either:
killshould treat an already-missing workspace as success (idempotent) and setterminated, orcleanupshould be able to reclaim sessions that areexitedbut notterminated.
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 doctorall green), the rest of the session lifecycle working normally. ao session cleanupoutput 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.