Usage limits¶
Each agent defines a USAGE_LIMITS constant passed to every run — a guardrail
against runaway agentic loops. request_limit caps model round-trips (each
tool-call iteration is one request); total_tokens_limit caps overall tokens. An optional spend cap in USD comes from AGENT_COST_LIMIT (off by default).
Exceeding any of them raises UsageLimitExceeded instead of silently burning
tokens. Tune the values in your agent module to fit your task; the supervisor
shares its budget with its workers so the limit bounds the whole delegation
tree.
Every agent also carries the RaiseContentFilterError capability, so a
response the provider filters (safety block or refusal) raises
ContentFilterError instead of being retried or returned half-finished. Like
UsageLimitExceeded, it propagates out of run_* for the caller to handle: