Files
cleveragents-core/scripts
freemo 3d2f9ae043 fix: count workers by last_active timestamp, not status API
The OpenCode /session/status endpoint reports all async workers as
"idle" even while they are actively processing — making the previous
--status busy filter always return empty and workers count as 0.

Fixes across the board:

- get_active_worker_tags() and count_active_workers(): new functions
  that filter by last_active >= (now - 2 min) instead of status field.

- Pool launcher: use count_active_workers() for the busy count, and
  extract exclude_numbers from active sessions' tags.

- Health cycle idle check: was using --status idle (returns all sessions
  since everything is "idle"). Now uses --status all + last_active
  threshold to find genuinely idle workers.

- Doom loop check: was using --status busy (returns nothing). Now uses
  --status all + last_active < (now - 30 min) to find abandoned sessions.

- fetch_list_script: guard against corrupted JSON when stderr messages
  from the script contaminate stdout — only accept output starting with
  "[" as valid JSON.

- Worker launch: add --restart so stale sessions are always replaced
  with fresh workers.

- Add IDLE_THRESHOLD_MS (3 min) constant for the health cycle.
2026-05-12 19:27:56 +00:00
..