Files
Nexus/web/agent/heartbeat_policy.py
T
Nexus Agent 972456a246 feat(agent): 401 停心跳、配置重载后重启与升级双文件下发
提取 heartbeat_policy;install/upgrade 同步 heartbeat_policy.py;config reload 恢复心跳协程。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 23:06:09 +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