Fix #12: the final hand-back after an interim stop always gets its line

EV-20 (PR #271) sat 8 h in router_check: after an interim stop in round 3 the
Opus dev's final hand-back got no "no verification" line.

- An agent that stays idle (waiting for a message, not on its own work) for
  2 minutes has handed back. A moment idle between turns does not count;
  waiting on background work stays an interim stop.
- Watches are kept in the store: a plugin reload cancels the timers, and the
  next event picks the stored watches up again.
- /router lists the agents still waiting for a hand-back, and for how long.

5 tests (one old test now goes idle briefly, then runs); 6 mutations, all caught.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MdqPWvuDpbpRvDEdURoAwo
This commit is contained in:
2026-11-24 02:08:24 +00:00
co-authored by Claude Opus 5.5
parent 2184024fe7
commit fade3b8bba
3 changed files with 177 additions and 11 deletions
+8
View File
@@ -407,6 +407,14 @@ export type LoopStatus = 'pending' | 'running' | 'waiting' | 'idle' | 'completed
export const turnEndKind = (status: LoopStatus | undefined): 'handback' | 'interim' =>
status === undefined || status === 'completed' || status === 'failed' || status === 'killed' ? 'handback' : 'interim'
/**
* How long an agent may stay `idle` before that counts as its hand-back (#12).
* `idle` waits for a message, not on its own work (that is `waiting`): one that
* stays idle has stopped and waits for the manager. A moment idle between turns
* is not a hand-back.
*/
export const IDLE_HANDBACK_MS = 2 * 60 * 1000
/** How often an interim agent's status is checked again, and for how long at most. */
export const WATCH_EVERY_MS = 15_000
export const WATCH_FOR_MS = 24 * 60 * 60 * 1000