Fix training agent heartbeat status

This commit is contained in:
Codex
2026-06-27 11:02:41 +03:00
parent b6d616ec2a
commit 83bffadc0a
5 changed files with 96 additions and 13 deletions
+10 -1
View File
@@ -206,9 +206,18 @@ class TrainingCoordinator:
last_seen = _parse_time(str(worker.get("last_seen_at") or ""))
active = self._active_job(state)
latest = _latest_job(state)
recently_seen = bool(last_seen and datetime.now(UTC) - last_seen <= ONLINE_WINDOW)
agent_busy = bool(
active
and active.get("status") == "running"
and worker
and active.get("claimed_by") == worker.get("id")
)
return {
"available": True,
"agent_online": bool(last_seen and datetime.now(UTC) - last_seen <= ONLINE_WINDOW),
"agent_online": recently_seen or agent_busy,
"agent_recently_seen": recently_seen,
"agent_busy": agent_busy,
"worker": worker,
"active_job": active,
"latest_job": latest,