[Bug]: Reboot leaves TUI sessions as live zombies until legacy tmux socket exists
Summary
After a hard Linux host reboot while TUI sessions are live, AO can keep those sessions as isTerminated=false / idle|working even though the tmux runtimes and Qwen processes no longer exist. Tasks are undeleteable "Stuck in Limbo" and the Orchestrator gets no fresh Session / is unusable
AO's normal reconciliation remains stuck while the legacy/default tmux socket is absent. Creating an otherwise-empty default tmux server immediately lets AO's own reaper recognize the stale sessions as dead, move them to Archive, and makes ao session restore <id> usable again.
Steps to reproduce
-
Start AO on Linux with multiple live TUI sessions (reproduced with Qwen workers and an orchestrator).
-
Reboot the host while those sessions are still live, so AO does not get a graceful shutdown.
-
Start AO again.
-
Observe that affected sessions are still reported as non-terminated, for example:
ao session get
--json returns states such as:
activity.state = idle isTerminated = false
even though no corresponding tmux runtime or agent process exists.
-
Confirm the runtimes are actually gone:
pgrep -af tmux tmux ls
The default tmux socket reports that it does not exist / cannot be connected to.
-
Try to close the stale session from the desktop UI or with:
ao session kill
This returns:
Internal server error (INTERNAL_ERROR)
and the session remains non-terminated.
-
Without modifying AO's database, create a harmless session on the legacy/default tmux server:
tmux new-session -d -s ao-recovery-probe 'exec sleep 3600'
-
Wait for AO's normal reconciliation/reaper (about 20 seconds in my reproduction).
-
Re-check the stale AO sessions. AO now marks the missing-runtime sessions terminated and they appear in Archive.
-
Restore one normally:
ao session restore
The runtime is recreated successfully. With Qwen, the persisted native Qwen session identity was used and the original Qwen conversation resumed.
-
Remove the temporary probe:
tmux kill-session -t ao-recovery-probe
Expected behavior
After a real host reboot where the recorded TUI runtime no longer exists, AO should reconcile the durable session with runtime reality without requiring a dummy tmux server or database modification.
If both AO's private tmux server and the legacy/default tmux server are absent, that should be treated as a definitively unavailable runtime for this reconciliation case, not leave the session indefinitely live-looking.
The stale session should become recoverably terminated/archived so ao session restore <id> can recreate the runtime and use provider-native resume where available.
ao session kill <id> should also be idempotent when the runtime is already gone rather than returning INTERNAL_ERROR.
Actual behavior
After the reboot, AO preserves the durable session row as non-terminated even though the tmux runtime and Qwen process are gone.
The desktop shows a disconnected/re-attaching terminal, while ao session get may still report idle or working. Tasks are "stuck" in Limbo and the orchestrator can not be used.
ao session kill <id> returns INTERNAL_ERROR and makes no durable state change.
The important additional observation is that simply starting an empty tmux server on the legacy/default socket fixes reconciliation:
tmux new-session -d -s ao-recovery-probe 'exec sleep 3600'
Once the default socket exists and can answer AO's probe, AO's own reaper marks the stale sessions terminated without any SQLite edit. They move to Archive and ao session restore <id> works normally.
This strongly suggests that "legacy/default socket absent" is being treated as an inconclusive runtime probe, while "legacy/default server exists but session is missing" is correctly treated as definitive absence.
This appears closely related to #4481 / PR #4482, but the observed failure is also in automatic post-reboot reconciliation, not only the explicit Kill path.
AO version
0.12.10
Environment
Ubuntu 26.04 amd64
Logs / extra context
Before submitting
- [x] I searched existing issues for duplicates
- [x] I removed secrets / tokens from logs and screenshots
Root cause (traced to exact lines)
Analyzed against 46741a59a (fork of recent main; the lines below verified identical on origin/main). macOS 26.6 arm64, packaged daemon, Homebrew tmux 3.6b.
The deadlock comes from the tmux output classifiers not recognizing how modern tmux reports "no server". With no tmux server at all, tmux 3.6b prints:
error connecting to /private/tmp/tmux-501/default (No such file or directory)
backend/internal/adapters/runtime/tmux/tmux.go classifies outputs like this:
serverNotRunningOutput()(~line 1188) only matches the older tmux textno server runningtransientServerFailureOutput()(~1203) matcheserror connecting→ treated as transient / inconclusivemigrationSocketAbsentOutput()(~1197) matcheserror connecting+no such file or directory, but it is only consulted when deciding whether to fall through from the private socket to the legacy default socket
Two consequences:
-
socketForSession()legacy fall-through (~line 957) checks onlysessionMissingOutput(legacyOut) || serverNotRunningOutput(legacyOut). With tmux 3.6b the legacy probe returns theerror connecting … (No such file or directory)text, which matches neither — so it returnsErrRuntimeProbeInconclusive, forever. Annotated log line (session names anonymized):level=DEBUG msg="reaper: probe error reported as failed fact" session=<orchestrator-a> err="tmux runtime: probe session <orchestrator-a>: runtime: liveness probe inconclusive: system tmux \"/opt/homebrew/bin/tmux\" could not inspect legacy default-socket session <orchestrator-a>: exit status 1: error connecting to /private/tmp/tmux-501/default (No such file or directory)"That exact line repeated 15,701 times in ~3 hours on my machine while the sessions stayed
isTerminated=false. -
IsAlive()(~568–579) likewise mapserror connectingviatransientServerFailureOutputto inconclusive; onlyno server runningis treated as conclusive server absence.
So the full deadlock is: probe inconclusive → reaper never concludes death → kill 500s (Destroy() ~504 aborts on the same inconclusive probe; this is the #4481 signature) → restore refuses with SESSION_NOT_RESTORABLE because the session is not terminal.
Why the workaround needed both sockets on the private-socket migration path
On my machine, a dummy server only on the default socket was not enough (code-traced; I did not test it standalone): once the legacy probe answers can't find session <id>, socketForSession() returns the private socket name, and IsAlive()'s final probe then hits the absent private server → error connecting → inconclusive again. I had to create sentinel servers on both tmux -L ao (the daemon runs with AO_TMUX_SOCKET_NAME=ao) and the default socket. Then:
- both probes answer
can't find session <id>→sessionMissingOutput→ conclusive(false, nil) - the reaper accepts the death;
ao session kill <id>succeeds (a missing session on a live server is already handled generously bykillSessionMissingOutput()) ao session restore <id>then relaunches with native resume, history intact
On the Linux repro above, default-only sufficed — plausibly an older tmux there still prints no server running, which the classifiers do recognize.
Also affected: ao session restart-all
The bulk recovery tool is blocked by the same kill failure. After a reboot with 9 live sessions (7 orchestrators on tmux-runtime records, 2 workers on the new pty-host runtime), restart-all reported restarted 3 of 9 — the pty-host workers recovered, every tmux-runtime session failed with kill: INTERNAL_ERROR. Only after the sentinel-socket workaround did per-session kill + restore bring all 7 back with --resume transcripts.
Fix direction
Treat error connecting … (No such file or directory) as definitive server absence (equivalent to no server running) rather than transient:
- include the socket-absent pattern in the legacy fall-through check in
socketForSession()(~957); - in
IsAlive(), classify that text asErrRuntimeUnavailableinstead ofErrRuntimeProbeInconclusive, so recovery may reconcile/recreate per the doc comment, instead of retrying forever.
This stays inside #3475's safety boundary: it is socket-level evidence (the socket file does not exist ⇒ no server can be reached there), not per-session death — per-session death still requires can't find session. Whether "runtime unavailable ⇒ mark archivable" belongs in the reaper is a policy call for maintainers, but something needs to conclude eventually: today the loop never ends, and neither the reaper nor kill/restore/restart-all can break it.
Happy to take a run at a PR if this direction looks right.
We hit this same root cause through a third trigger path: auto-review launching a reviewer harness, with no reboot involved.
Every auto-review attempt failed before the reviewer started:
launch reviewer: reviewer replace stale pane: tmux runtime: destroy session review-<session>:
runtime: liveness probe inconclusive: system tmux "/opt/homebrew/bin/tmux" could not inspect
legacy default-socket session review-<session>: exit status 1:
error connecting to /private/tmp/tmux-501/default (No such file or directory)
The reviewer pane never existed in the first place, so AO blocked on exactly the condition proving it could not exist: there was no legacy tmux server at all.
Environment
| AO | 0.12.12 (also seen on 0.12.11), desktop app |
| OS | macOS 26.5.2 (build 25F84), arm64 |
| Bundled tmux | 3.5a |
| System tmux | 3.7c (Homebrew, /opt/homebrew/bin/tmux) |
| Reviewer harness | codex |
| Permission mode | auto |
Two things that made this hard to diagnose
1. ao doctor reports tmux as PASS. It resolves the bundled binary and says so, which reads as "tmux is fine" while the failure message blames tmux. But the legacy default-socket probe will not use the bundled binary, so on a machine with no tmux on PATH the earlier failure is:
... cannot inspect legacy default-socket session review-<session> because system tmux is unavailable
Installing a system tmux only moves the error along to the socket-absent case above. Worth considering whether the doctor check should report the system slot separately, since one code path depends on it.
2. The bug only bites when the default socket file has never existed. If the socket file exists but its server has exited, tmux says no server running on ..., which the current code already accepts as definitive. Only a never-created socket produces error connecting ... (No such file or directory). That is the normal state on a machine that never uses tmux interactively, and it explains why this can look intermittent or environment-specific.
Workaround
Keeping any tmux server alive on the default socket resolves it, because probing a missing session then returns can't find session: ..., which is already handled:
tmux new-session -d -s ao-probe-keepalive 'while :; do sleep 3600; done'
We run that from a LaunchAgent at login so it survives reboots. Creating a decoy session named after the specific reviewer pane also works, but only for that one session name.
On the fix
We independently traced this to socketForSession in backend/internal/adapters/runtime/tmux/tmux.go omitting the absent-socket matcher from its legacy-branch check, and were about to open a patch when we found #4859 already does exactly that, plus the equivalent branch in IsAlive. It looks correct for our case too, so we would rather see that land than add a competing PR. Happy to test a build if that helps.
One note for whoever merges: auto-review has a cap of 3 attempts per PR head commit, so a session that burned its attempts on this bug will not retry by itself even after the fix ships. Ours needed ao review trigger <worker-session-id> to recover.
This comment was generated by a Claude Code Agent.
Same failure on the latest release, through the auto-review path described above: every review launch for a worker PR failed until a tmux server was running on the default socket.
| AO | 0.13.0 (desktop app) |
| OS | macOS 26.6.2 (25G83), arm64 |
| Bundled tmux | 3.5a |
| System tmux | 3.7c (Homebrew) |
| Reviewer harness | claude-code |
Two additions to the report above:
- Still reproduces on 0.13.0. The legacy-branch check in
socketForSessionis unchanged at thev0.13.0tag (tmux.go:990), and #4859 is still open. - Installing a system tmux needs a daemon restart to take effect. With no
tmuxonPATHthe error iscannot inspect legacy default-socket session … because system tmux is unavailable. Afterbrew install tmuxthe same error kept coming back until the AO app was quit and reopened, because the system binary is looked up once when the runtime is built at daemon start (tmux.New→exec.LookPath("tmux"), called fromdaemon.goviaruntimeselect.New). Only after the restart did the error change to the socket-absent case, and only a server on the default socket cleared it.
Agent-collected evidence
Collected 2026-09-13 on the affected machine, AO 0.13.0; source references checked against v0.13.0 and main at cadde8c9fd20.
Before the restart, with /opt/homebrew/bin/tmux already installed:
launch reviewer: reviewer replace stale pane: tmux runtime: destroy session review-<session>: runtime: liveness probe inconclusive: cannot inspect legacy default-socket session review-<session> because system tmux is unavailable
After restarting the app:
launch reviewer: reviewer replace stale pane: tmux runtime: destroy session review-<session>: runtime: liveness probe inconclusive: system tmux "/opt/homebrew/bin/tmux" could not inspect legacy default-socket session review-<session>: exit status 1: error connecting to /private/tmp/tmux-501/default (No such file or directory)
Workaround that unblocked review launches (ao review trigger → started a new review, run status running):
tmux -L default new-session -d -s ao-legacy-socket-placeholder 'while :; do sleep 3600; done'
tmux -L default has-session -t '=review-<session>' # → can't find session: review-<session>
ao doctor reported PASS tmux (bundled binary) throughout.
This comment was drafted by a Claude Code agent and posted with the reporter's approval.
Same root cause hits the reviewer launch path, not only session reconciliation. macOS 27.0 arm64, AO 0.13.0 desktop, Homebrew tmux 3.7c.
After a reboot (no tmux server, /private/tmp/tmux-501/default absent), every reviewer launch fails — three auto-review attempts a minute apart on one PR and a manual ao review trigger on another, all with:
launch reviewer: reviewer replace stale pane: tmux runtime: destroy session review-<session>: runtime: liveness probe inconclusive: system tmux "/opt/homebrew/bin/tmux" could not inspect legacy default-socket session review-<session>: exit status 1: error connecting to /private/tmp/tmux-501/default (No such file or directory)
review_run.status = failed, ao review ls shows needs_review. Same workaround: tmux new-session -d -s ao-keepalive, then ao review trigger succeeds on the first try.
Side effect worth a separate look: while the review run was failed, the board card moved Validating → Ready (CI green + mergeable, review none), so the missing review was invisible on the board. Filed as a separate board issue.
Assigned to @codebanditssss
the issue is valid and the current main branch still leaves a gap: modern tmux reports an absent socket as error connecting ... no such file or directory, but ao classifies that as an inconclusive probe, so reaper, kill, restore, and restart-all can remain stuck indefinitely. the fix should classify an actually absent tmux socket/server as runtime unavailable after the private/legacy socket checks, while keeping connection-refused and other ambiguous failures inconclusive. pr #4859 appears to implement this; pr #4797 only covers the older tmux wording.
Thanks for the triage — confirming that #4859 implements exactly that semantics: an absent socket file is classified as conclusive server absence, but only after the private and legacy default-socket checks; connection-refused and other ambiguous failures remain inconclusive. The branch is rebased on the latest main and ready for review.