Quick Start
How It Works
Every structured error carriesmessage, agent_id, run_id, error_category, and is_retryable. Subclasses add domain fields such as tool_name or model_name.
The Error Hierarchy
| Class | Parent | When raised | Key fields | Default retryable |
|---|---|---|---|---|
PraisonAIError | Exception | Base — catch-all | error_category, context | False |
ToolExecutionError | PraisonAIError | Tool fails or loop-guard HALT | tool_name | True |
LLMError | PraisonAIError | Chat completion fails | model_name | False |
ValidationError | PraisonAIError | Invalid config or input | field_name | False |
NetworkError | PraisonAIError | External service unreachable | service_name, status_code | True |
error_category uses typed kinds such as rate_limit, auth, context_overflow, and billing — useful for logging and selective retry policies.
Common Patterns
Retry on transient network failures, fail on config bugs:Choose Your Recovery
Best Practices
Catch the most specific class you can handle
Catch the most specific class you can handle
Use
ToolExecutionError when you only care about tool failures; reserve PraisonAIError for top-level logging.Log structured context
Log structured context
Include
e.error_category, e.agent_id, and e.run_id in observability hooks — they correlate across multi-agent runs.Don't swallow ValidationError
Don't swallow ValidationError
Validation failures usually mean a programming or config bug. Fix the root cause instead of retrying blindly.
Pair with loop guard for retry loops
Pair with loop guard for retry loops
Loop-guard
HALT raises ToolExecutionError. Combine with Loop Guard when tools may repeat indefinitely.Related
Loop Guard
Stop runaway tool loops with HALT/WARN/BLOCK
Non-Fatal Errors
Callback failures captured without crashing
Async Tool Safety
Circuit breakers for async tool calls
Custom Tools
Build tools that raise clear errors

