evaluate_channel_health
Function
This function is defined in the protocols module.Evaluate channel health and return a reason. Pure function that evaluates a HealthResult and determines the health reason based on various criteria. Liveness is driven by passive inbound transport activity (
health.last_activity) rather than only an outbound probe, and the
evaluator is aware of in-flight agent runs (health.active_runs) so a
busy channel is never mistaken for a dead socket:
- busy with recent inbound progress ->
BUSY(never restarted); - busy but no progress beyond
stuck_after_seconds->STUCK; - idle and inbound stale beyond
stale_after_seconds->STALE_SOCKET.
health.last_activity) and in-run progress
(health.last_run_progress — tool calls, streamed draft edits, token
output, or a periodic heartbeat). A single long agent run that streams
output or emits tool events the whole time therefore stays BUSY
indefinitely instead of being torn down mid-run once its wall-clock
crosses stuck_after_seconds; only a run that emits nothing for
stuck_after_seconds is flagged STUCK.
Signature
Parameters
HealthResult
required
The health result to evaluate
float
default:"60.0"
Grace period for startup
float
default:"120.0"
Time after which no inbound activity is stale
float
default:"900.0"
Time after which a busy channel with no progress is considered stuck
Optional[float]
Current timestamp (for testing)
Returns
HealthReason
HealthReason indicating the channel’s health status
Uses
time.time
Source
View on GitHub
praisonaiagents/bots/protocols.py at line 688
