> ## 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

Function

> This function is defined in the [**protocols**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/protocols.md) 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

**health** `HealthResult` *required*

The health result to evaluate

**startup\_grace\_seconds** `float` (default: 60.0)

Grace period for startup

**stale\_after\_seconds** `float` (default: 120.0)

Time after which no inbound activity is stale

**stuck\_after\_seconds** `float` (default: 900.0)

Time after which a busy channel with no progress is considered stuck

**current\_time** `Optional[float]`

Current timestamp (for testing)

### Returns

**Returns** `HealthReason`

HealthReason indicating the channel's health status

## Uses

* `time.time`

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/bots/protocols.py#L891)
>
> `praisonaiagents/bots/protocols.py` at line 891

***

## Related Documentation

> [card] [Evaluation Concept](https://praison.ai/docs/docs/concepts/evaluation)

> [card] [LLM as Judge](https://praison.ai/docs/docs/features/llm-as-judge)

> [card] [Evaluation Loop](https://praison.ai/docs/docs/eval/evaluation-loop)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.