Evaluate Pressure • AI Agent SDK
evaluate_pressure: Pure, deterministic classification of gateway load. No I/O.
evaluate_pressure
Function
</div>
This function is defined in the protocols module.
Pure, deterministic classification of gateway load. No I/O.
Reads back facts the enforcement layer already computes (`AdmissionGate.stats(), the outbox status counts, the watchdog's measured lag) and folds them into a single :class:HealthPressure. Lives in core — like :func:compute_config_revision` — so the SDK and the bot classify identically without divergence.
Classification (highest wins):
- `
"saturated"` — admission is full and work is queuing, the outbound - dead-letter tier is non-empty, or the event loop is lagging badly
- (`
>= 500 ms`): shed / stall is imminent or occurring. - `
"elevated"— admission is highly utilised (>= 80 %`), the inbound - or outbound backlog is building, or the loop is lagging (`
>= 100 ms`). - `
"nominal"` — none of the above.
Signature
def evaluate_pressure() -> HealthPressureReturns
ResponseField
HealthPressureclass:HealthPressure ready for the health surface.
Uses
HealthPressure
Source
View on GitHubpraisonaiagents/gateway/protocols.py at line 1659