Runtime restore recreates the tmux session but never relaunches the agent — zombie session reports idle and holds its branch
Summary
When the daemon restarts, it recreates a session's tmux session but does not relaunch the agent inside it. The result is a zombie: AO reports the session as alive and idle, but the tmux pane is a bare zsh with no agent running. The zombie keeps its git worktree and holds its branch checked out, which blocks any new spawn on that branch — while doing no work.
Because the daemon is now owned by the desktop app, this is easy to hit: closing the app window kills the daemon, the tmux server, and every running agent. On the next launch, the sessions come back as zombies.
Steps to reproduce
ao spawn --project <p> --branch <b> --prompt '...'— confirm the agent is running (ps aux | grep 'claude --session-id', tmux pane shows the agent).- Quit the desktop app (or otherwise stop the daemon).
- Relaunch the app so the daemon comes back.
- Look at the restored session.
Observed
The tmux session is recreated, with a fresh timestamp:
$ tmux ls
fireddd-github-io-3-90ce67e1: 1 windows (created Wed Jul 15 00:12:28 2026)
But there is no agent in it:
$ tmux list-panes -t fireddd-github-io-3-90ce67e1 -F "#{pane_current_command}"
zsh # <-- bare shell, not the agent
$ ps aux | grep -c "[c]laude --session-id"
0 # <-- agent is gone
AO nonetheless reports the session as healthy and non-terminated:
$ ao session get fireddd.github.io-3
id: fireddd.github.io-3
name: Verify the nav fix
role: worker
status: idle
activity: idle
harness: claude-code
terminated: false # <-- looks alive
And it still owns its branch, so a fresh spawn on that branch is refused:
$ ao spawn --project fireddd.github.io --branch ao/verify-nav --prompt '...'
spawn fireddd.github.io-4: workspace: workspace: branch is already checked out in another worktree:
"ao/verify-nav" is checked out at ".../worktrees/fireddd.github.io/fireddd.github.io-3"
(BRANCH_CHECKED_OUT_ELSEWHERE)
The only way forward is ao session kill fireddd.github.io-3 to free the branch, and re-spawn from scratch — losing whatever the agent had in flight.
Expected
One of:
- Relaunch the agent on restore. The adapter already supports this — the Claude Code adapter pins a stable
--session-idat launch specifically soGetRestoreCommandcan rebuildclaude --resume <uuid>(seebackend/internal/adapters/agent/claudecode/claudecode.go). If the runtime is being restored, the agent should be restored into it too. - Or mark the session as dead when the runtime comes back without an agent, so it stops claiming to be
idle, releases its worktree/branch, and is visible as something the user must restart.
What should not happen is the current middle state: a session that reports idle / terminated: false, occupies its branch, and has no agent in it. It looks healthy while being permanently stalled, and nothing surfaces the fact that the agent died.
Notes
- Worth considering a warning when the app is closed with live agent sessions — quitting the window silently terminating N running agents is surprising, especially now that the daemon's lifetime is tied to the app.
- Detection is cheap: the pane's
pane_current_commandis the bare shell and no agent process exists for the session. The reaper already logs adjacent conditions (session has no runtime handle metadata, skipping).
Environment
| Version | efc8969 (tmux runtime) |
| OS | macOS, Darwin 25.3.0 (arm64) |
| tmux | 3.6a |
| Harness | claude-code (2.1.209) |
Related: #2699 (spawn/runtime error handling).
Thanks for contributing to Agent Orchestrator.
This issue is being picked up by the current external contributor on-call pair:
- @neversettle17-101
- @somewherelostt
If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @neversettle17-101 and @somewherelostt here.
For faster context or live questions, you can also join the AO Discord.
Join the session here: https://discord.gg/H6ZDcUXmq
Come by if you want to see what is being built, ask questions, or just hang around with the community.
+1 — hit this via a different trigger: macOS sleep / reboot, not closing the app window.
When the Mac sleeps (or reboots), the daemon, the tmux server, and every running agent die together. On wake/boot AO relaunches as a login-item, and a subset of previously-active sessions come back as terminated rather than being auto-restored — the daemon-start auto-restore did not relaunch them. (Not the zombie shape from the OP: they are marked terminated, not alive-with-bare-zsh.)
What does work for me: manual ao session restore <id> relaunches the agent correctly — the tmux session is recreated and the claude agent restarts inside it via claude --resume <uuid>, with the branch and uncommitted changes intact. So the restore machinery itself is fine; the gap is that daemon-start auto-restore does not run for these sessions after a sleep/wake.
Confirmed across 6 worker sessions — manual restore brought all of them back with live agents.
Separately: orchestrator sessions are the more painful case here — restore did not relaunch the orchestrator cleanly and I had to respawn and /resume manually. I'm mid-work and can't repro the crash right now, but will file a focused repro for the orchestrator restore asymmetry once I can.
Workaround for macOS users in the meantime: caffeinate -d (or -i) keeps the system/display awake so the daemon, tmux, and agents are not killed by sleep in the first place — I run it while long worker sessions are active.
Possibly related: #2415 (keep the restore marker when a relaunch fails transiently).
Happy to add ao session get dumps / logs if useful.
+1 — hit a related-but-distinct shape of this on an orchestrator session after the daemon/tmux/agent were killed (Mac sleep).
Unlike the OP's "zombie" (tmux recreated, bare zsh, but terminated: false + reported alive/idle), mine landed in a different inconsistent state:
$ ao session get <id>
status: exited
activity: exited
terminated: false
So AO's own activity tracking correctly detected the agent was gone (exited), but terminated stayed false. That mismatch is fatal for recovery, because ao session restore only operates on sessions where terminated: true:
$ ao session restore <id>
Session is not restorable (SESSION_NOT_RESTORABLE)
Inside the tmux pane itself, the harness had already failed to resume its own conversation:
No conversation found with session ID: <uuid>
ao hooks agent-process process-exited: AO daemon is not running — start it with `ao start`
(daemon was actually running fine at the time — healthz returned 200 — so that second line looks like a stale/misleading message from a hook that fired during the restart race, not an accurate daemon-down report.)
Net effect: the session is stuck in a state CLI has no verb for — not "terminated" (so restore refuses), not actually alive (so nothing in the UI works either). The only path out appears to be ao session kill first (destructive, throws away the option of a clean auto-resume) followed by a manual respawn — restore itself has no way in.
Seems like the same root cause as the OP: daemon-restart/session-restore doesn't reconcile terminated/status/activity consistently with what actually happened to the underlying process, and orchestrator sessions in particular don't have a clean recovery path once that happens. Might be worth restore (or a new reconcile/resync verb) also accepting sessions where activity=exited but terminated=false, rather than only terminated=true.
Happy to share more ao session get output / daemon logs if useful — will keep specifics generic since this is from a private project.
Closing as already implemented in the current restore path. RestoreWithMode rebuilds the provider restore command and relaunches it through the runtime (using RuntimeRestarter when available), rather than merely recreating an empty tmux session.