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

bug(core): manually running Claude in orphaned tmux revives stuck session on dashboard

Open OrcInc opened this issue 6 months ago • 1 comments

Bug

After a Claude session is stopped from the dashboard terminal (Ctrl+C) and the session ends up in stuck state (per #1966), manually running claude inside the orphaned tmux session causes the dashboard to show the session as active/working again.

Discord thread: https://discord.com/channels/1484900948397199371/1491735678156013588/1506746218020212926 Reported by: @Hr!shi! (hrishic7) Analyzed against: ecdf0c73 (main, 2026-05-20) AO version: 0.8.0

Reproduction

  1. ao start with a Claude Code agent
  2. Ctrl+C the Claude session from the dashboard terminal → session goes to stuck (bug #1966)
  3. SSH into the server, tmux attach to the AO-managed tmux session
  4. Run claude manually inside the tmux
  5. The web dashboard shows the previously-stuck session as working / active

Root Cause

Two bugs compound:

  1. #1966: Session ends up stuck with probe_failure instead of terminated — tmux stays alive
  2. This bug: The lifecycle manager revives stuck sessions when it detects agent activity

The revival path in determineStatus():

  • lifecycle-manager.ts:1356-1387: The isWeakActivityEvidence() guard only preserves stuck state for weak signals (unavailable, stale)
  • When Claude is manually running, the activity signal is strong (valid with activity=active)
  • The guard is bypassed, code falls through to lifecycle-manager.ts:1389-1401
  • Line 1392: session.status === SESSION_STATUS.STUCK matches
  • Returns WORKING with sessionState: "working", sessionReason: "task_in_progress"
  • Dashboard shows the session as active again

There is no check for whether the session was previously terminated/stuck due to agent exit, whether the agent was manually launched by AO, or whether the runtime handle is still valid. Any process matching the agent plugin's isProcessRunning() check in the tmux session will revive it.

Why this is wrong

The tmux session is an orphan — AO lost track of the agent. A human manually starting Claude in that tmux is not an AO-managed session. The dashboard should not show it as a managed working session. This creates confusion about what AO is actually orchestrating.

Fix

Two options (both address #1966 and this bug):

Option A (minimal, addresses both): Fix #1966 first — when the agent process exits and runtime is alive, transition to terminated instead of detecting → stuck. Once properly terminated, the lifecycle manager won't poll it anymore and manual Claude usage in the tmux won't revive it.

Option B (defense in depth): Add a guard in the STUCK → WORKING transition path (line 1389-1401) that checks:

  • Was the session previously killed or terminated? If so, don't revive.
  • Is the agent process PID the same one AO spawned? If not, don't revive.

Option A fixes the root cause (session should have been terminated). Option B adds belt-and-suspenders protection against revival of any dead session.

Confidence: High — traced the exact revival code path.

File:index

  • Stuck → Working revival: packages/core/src/lifecycle-manager.ts:1389-1401
  • Weak evidence guard (bypass): packages/core/src/lifecycle-manager.ts:1356-1387
  • Activity signal classification: packages/core/src/activity-signal.ts

Related

  • #1966 — stopping Claude from dashboard terminal goes through detecting → stuck instead of terminating (root cause of orphaned tmux)
  • #1933 — stuck session with exited runtime never auto-promotes to terminated
  • PR #1945 — hooks-based activity detection for Claude (changed how activity is detected)

OrcInc avatar May 20 '26 20:05 OrcInc

This issue was created before the AO rewrite and refers to implementation that no longer exists in the current Go/Electron codebase, so we’re closing it as part of the repository cleanup.

If the same user-visible issue still exists in the latest version of AO, feel free to open a new issue with updated details, reproduction steps, logs, and screenshots where applicable. Please describe the current behavior rather than the removed TypeScript implementation.

AO is now available as an app on macOS and Windows, with iOS currently in beta and Android coming soon.

Stay connected with AO:

GitHub: https://github.com/AgentWrapper/agent-orchestrator Discord: https://discord.gg/kGbBRRDPv X: https://x.com/aoagents LinkedIn: https://www.linkedin.com/company/agent-orchestrator Instagram: https://www.instagram.com/aoagents

illegalcall avatar Jul 25 '26 06:07 illegalcall