Files
Nexus/web/agent/heartbeat_policy.py
T
2026-07-08 22:31:31 +08:00

19 lines
529 B
Python

"""Heartbeat loop stop conditions — shared by agent.py and unit tests."""
from __future__ import annotations
from typing import Any, Mapping, Optional
def heartbeat_should_stop(
status_code: int,
body: Optional[Mapping[str, Any]] = None,
) -> bool:
"""True when central rejected heartbeat permanently (do not retry)."""
if status_code == 401:
return True
if status_code == 200 and isinstance(body, Mapping):
if body.get("status") == "discarded":
return True
return False