[Bug] v0.8.0 supervisor restarts make every TUI fail to reattach with “Unknown active session” #1641
Replies: 2 comments
|
I observed another instance of this failure and found two concrete races in the current reconnect path. 1. A healthy replacement supervisor can be shut down as staleThe sequence was: The relevant client log was: The supervisor log shows that the replacement announced readiness immediately before the shutdown decision: The command journal confirms that a reconnecting daemon client then sent the shutdown command. The replacement itself was healthy by that point. The race appears to be in
A minimal safety rule would be: no hello means 2. Generic reconnect reuses a supervisor-scoped activeSessionIdAfter the next supervisor started, the TUI repeatedly failed with:
The same class already has the safer pattern in In this incident, the replacement had already restored and listed the sessions, so no new daemon command or protocol change was required. The minimal fix appears to be:
I also verified that both code paths are still present on the current upstream I can prepare focused regression tests for the delayed-hello race and the changed-activeSessionId reconnect case if maintainers confirm this direction. |
|
I can vouch this is also an error as well, please open a PR if not already done |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
The shared daemon supervisor disappears several times per day. Every open TUI then shows:
This affects all active agents on the machine at the same time. The session workers often remain alive, but the replacement supervisor does not restore all active-session mappings. The TUIs keep retrying their old IDs and cannot reattach.
I first noticed this after Prime Agent performed its first self-update. I cannot prove that the update caused the initial supervisor failure. The local logs do show that the issue continued after a successful v0.8.0 update handoff.
Environment
0.8.0, global npm installv24.16.026.6on Apple Silicon~/.prime/agentstateprime-agent status --jsonreported 28 sessions after the latest recovery.~/.prime/agent-beta.Frequency and impact
I see the user-facing failure at least three times per day. It interrupts every open Prime Agent TUI, including agents that were still working.
The current daemon log spans several package versions. It contains 40 supervisor generations and 41 worker messages that say they launched a replacement supervisor. This is not one isolated stale session.
Latest incident
The v0.8.0 update restart record started at
2026-08-21T21:34:14Zand completed with:{"total":14,"restored":14,"resumed":2,"failed":0}From that handoff through
2026-08-22T02:25:46Z, the log recorded 10 different supervisor generations.At the latest replacement, the new supervisor tried to adopt existing workers:
For that startup:
Unknown active sessionattach failures: exactly 9 active IDs retried 17 times each.lifecycle: "failed"withlastError: "Waiting for a client with fresh runtime context".The prior supervisor's last log line was a normal worker-listening event five minutes earlier. There was no graceful shutdown, update-restart notice, SIGTERM, or fatal record before it disappeared.
Racing replacement attempts also produce many instances of:
What seems to be happening
The secondary failure is clear from the logs: supervisor recovery fails to adopt several live workers. Startup gives each worker connection about two seconds. After the recovery retries fail, resident workers without fresh client context become
failed.Each failed descriptor still contains its durable
rootActiveSessionId. However,findWorker()only searches the worker's populated session summaries. It does not fall back to the descriptor's root ID or saved session file. Each TUI then retries its previous ID and getsUnknown active session.The first supervisor failure is less certain. Two existing reports match the evidence:
acquireDaemonSocketPathLeasestill uses a 5-second stale window and 1-second refresh without anonCompromisedhandler.proper-lockfilecan throw from its refresh callback after another process takes the lease. That could explain why the old supervisor ends without a final log line.I have not captured an
ECOMPROMISEDerror, so #1556 is a likely cause, not a confirmed cause. The detached supervisor launch discards stderr, which may explain why the decisive uncaught exception is absent.Related reports:
onCompromisedRecovery result
The internal
retry_workerpath works, but v0.8.0 does not expose it through the public command router. This command fails:I invoked the installed internal retry handler against failed descriptors whose worker PID and socket were still alive:
failedtoready.prime-agent list --jsonagain.This recovered the sessions without a global daemon shutdown. It also confirms that the durable descriptor contains enough data to repair the active-session mapping. A public retry command or automatic use of this path during reconnect would reduce the impact.
If internal retry fails, reopening the saved transcript is safer than deleting daemon lock files.
prime-agent shutdown --forceis a last resort because it stops all sessions.Expected behavior
Questions
~/.prime/agent/logs/agent.jsonl?onCompromisedhandler and a longer or adaptive stale window?I can provide a larger sanitized log slice if useful. I have omitted session paths, prompts, tokens, and worker authentication data.
All reactions