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

bug(activity): nothing demotes a stale active state for harnesses without a TerminalActivityDetector

Open Annieeeee11 opened this issue 1 month ago • 0 comments

What went wrong?

For most harnesses, nothing demotes a stale active activity state. If a turn ends without the hook that reports it, the session reads Working forever. This is the general form of #3387 (Layers 1 and 3), which #7433 fixes only for Kimi's provider-error path.

Two pieces are missing:

  1. Status derivation has no staleness check. contract.DeriveStatus (backend/pkg/contract/status.go, called from service/session/status.go) maps ActivityActive to StatusWorking however old LastActivityAt is.
  2. The stale-activity observer covers only harnesses that implement ports.TerminalActivityDetector. Today that's aider, claude-code, cline, codex, continue, crush, hermes, kiro, memcode and muse. The observer skips every other terminal harness, including opencode, opencode-v2, grok, droid, amp, agy, cursor, qwen, gemini, copilot, goose, auggie, devin, kimi, kilocode, vibe, pi, kimchi, prime-agent, autohand, omp, codewhale, mimo-code, openhands and command-code. Some of these may only run in Chat, where the controller reports turn ends; that needs checking per harness.

The same family shows up per harness: #3387 (kimi), #5050 (agy, Esc interrupt), #6131 (orchestrator on claude-code), #4142 and #3115 (closed, fixed per harness with a detector).

Why a simple time-based decay isn't enough

#3387's Option B (decaying active after N minutes) would wrongly flag long turns that only run tools, for harnesses that report nothing mid-turn: Kimi until #7399, and any adapter without tool hooks. A general fix has to tell "the turn ended silently" apart from "the turn is long and quiet".

Possible directions

  • Per-harness detectors, the way #4142 and #4048 were fixed: authoritative idle from each TUI's idle composer. This is accurate, but each one also changes message-delivery readiness for that harness, so it needs real frames.
  • Process-level evidence: a session whose agent process is alive and idle (no CPU, no output) for a long time while it reads active could move to a distinct "possibly stuck" status rather than idle. That surfaces the problem without claiming the turn ended.
  • A "stale" status in deriveStatus() that only applies when no detector exists and the adapter reports mid-turn activity, so long quiet turns stay working.

Done when

A turn that ends without its end hook no longer leaves the session on "Working" indefinitely, on any harness. Either a detector or some other signal moves it to idle or to a visible "stuck" state, and long tool-only turns aren't misreported.

Related: #3387, #7433, #6131, #5050, #4145.

Annieeeee11 avatar Oct 30 '26 12:10 Annieeeee11