> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Evaluate Channel Health • AI Agent SDK

> evaluate_channel_health: Evaluate channel health and return a reason.

# evaluate\_channel\_health

<div className="flex items-center gap-2">
  <Badge color="teal">Function</Badge>
</div>

> This function is defined in the [**protocols**](../modules/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`.

For the busy branch, "progress" is the most recent of inbound transport
activity (`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

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def evaluate_channel_health(health: HealthResult, startup_grace_seconds: float, stale_after_seconds: float, stuck_after_seconds: float, current_time: Optional[float]) -> HealthReason
```

## Parameters

<ParamField query="health" type="HealthResult" required={true}>
  The health result to evaluate
</ParamField>

<ParamField query="startup_grace_seconds" type="float" required={false} default="60.0">
  Grace period for startup
</ParamField>

<ParamField query="stale_after_seconds" type="float" required={false} default="120.0">
  Time after which no inbound activity is stale
</ParamField>

<ParamField query="stuck_after_seconds" type="float" required={false} default="900.0">
  Time after which a busy channel with no progress is considered stuck
</ParamField>

<ParamField query="current_time" type="Optional[float]" required={false}>
  Current timestamp (for testing)
</ParamField>

### Returns

<ResponseField name="Returns" type="HealthReason">
  HealthReason indicating the channel's health status
</ResponseField>

## Uses

* `time.time`

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/bots/protocols.py#L688">
  `praisonaiagents/bots/protocols.py` at line 688
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Evaluation Concept" icon="gavel" href="/docs/docs/concepts/evaluation" />

  <Card title="LLM as Judge" icon="scale-balanced" href="/docs/docs/features/llm-as-judge" />

  <Card title="Evaluation Loop" icon="rotate" href="/docs/docs/eval/evaluation-loop" />
</CardGroup>
