972456a246
提取 heartbeat_policy;install/upgrade 同步 heartbeat_policy.py;config reload 恢复心跳协程。 Co-authored-by: Cursor <cursoragent@cursor.com>
19 lines
529 B
Python
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
|