Quick Start
How It Works
Every agent execution produces anAgentRunOutcome with a typed status that enables exhaustive pattern matching:
| Status | Meaning | Retryable | When It Occurs |
|---|---|---|---|
success | Completed successfully | No | Agent produced valid output |
failure | Non-retryable logic error | No | Unhandled exception, logic error |
timeout | Operation exceeded time limit | Yes | Slow LLM, network hang |
cancelled | External cancel signal | No | User Ctrl-C, parent cancelled child |
invalid_output | Output didn’t pass validation | Yes | Wrong format, validator rejected |
The Five Statuses
| Status | Meaning | Retryable | Typical Cause |
|---|---|---|---|
success | Completed successfully | No | Agent produced valid output |
failure | Non-retryable logic error | No | Unhandled exception, validation logic error |
timeout | Operation exceeded time limit | Yes | Slow LLM, slow tool, network hang |
cancelled | External cancel signal | No | User Ctrl-C, parent agent cancelled child |
invalid_output | Output didn’t pass validation | Yes | Wrong format, missing fields, validator rejected |
Creating Outcomes
Create outcomes using factory methods — each sets appropriate defaults automatically.Retry Decisions
Useis_retryable() to determine if an operation can be retried safely.
Reading the Outcome From a Task
After task validation routing, check both the new typed outcome and legacy feedback.HandoffResult Integration
Handoff results now include typed outcomes automatically derived from legacy fields.Migration from String-Based Validation
Replace string parsing with typed status matching for safer code. Before:Decision Flow
Best Practices
Prefer status matching over string parsing
Prefer status matching over string parsing
Always match against the typed
status field instead of parsing error messages or legacy strings.Use `is_retryable()` to drive retry logic
Use `is_retryable()` to drive retry logic
Let the outcome determine retry behavior instead of hardcoding status lists.
Put structured data in `context`, not in `error`
Put structured data in `context`, not in `error`
Use the
context field for machine-readable metadata, keep error human-readable.Always handle all five statuses
Always handle all five statuses
Exhaustive matching prevents bugs from unhandled cases. Avoid fall-through
else clauses.Related
Task Validation & Feedback
Task validation with typed outcomes
Agent Handoffs
Agent-to-agent delegation with outcomes

