AgentRunOutcome (this page) and RunOutcome (see Run Outcome) are two different types with two different jobs:- Python
- TypeScript
AgentRunOutcome instead of an ambiguous string.
Quick Start
1
Simple Usage
Every agent execution returns an
AgentRunOutcome that you can check for success.2
Exhaustive Matching
Match all five status types exhaustively to handle every possible outcome.
3
Validation Routing
Access typed outcomes from task validation instead of parsing strings.
How It Works
Every agent execution produces anAgentRunOutcome with a typed status that enables exhaustive pattern matching:
The Five Statuses
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:Process normalises its routing key with .lower().strip() — the same normalisation validate_decision_string applies at praisonaiagents/run_outcome.py:303. Before the fix in MervinPraison/PraisonAI#4260, the two disagreed on a whitespace-padded verdict like "invalid\n"; now they agree, so the typed outcome is reliably stored even when the model pads its verdict.
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.CLI Mapping (praisonai run)
The praisonai run CLI wraps the SDK outcome into a success / truncated / failure exit signal for pipelines: any falsy or empty result (None, "", all-whitespace) exits 1 with a machine-readable run_failed payload, unless the core recorded a provider block/refusal/truncation — in which case the specific reason wins and exits 2 with the reason as status. A non-empty result that hit the step limit exits 2 with a truncated payload; any other non-empty result exits 0 with the existing text/JSON output.
See
praisonai run → Exit Codes for the full CLI contract, the failure and truncated payload schemas, and CI usage examples.
The SDK-level statuses stay available programmatically for Python/YAML users who want fine-grained matching. On the CLI, step-limit truncation is now surfaced distinctly (exit
2, status: "truncated") rather than masked as success — see Exit Codes.Related
Task Validation & Feedback
Task validation with typed outcomes
Agent Handoffs
Agent-to-agent delegation with outcomes

