Agent Run Outcome • AI Agent SDK
AgentRunOutcome: Structured outcome for agent execution, validation, and handoff operations.
AgentRunOutcome
Defined in the Run Outcome module.
AI Agent
Structured outcome for agent execution, validation, and handoff operations.
Replaces freeform string parsing with typed status values that callers can match exhaustively. Provides structured metadata for debugging and retry policies.
Properties
RunStatusNo description available.
Optional[str]No description available.
Optional[str]No description available.
Optional[str]No description available.
floatNo description available.
Optional[str]No description available.
Optional[str]No description available.
OptionalNo description available.
Methods
Create a successful outcome.
failure()Create a general failure outcome.
timeout()Create a timeout outcome.
cancelled()Create a cancelled outcome.
invalid_output()Create an invalid output outcome.
is_success()Check if the outcome represents successful completion.
is_failure()Check if the outcome represents any kind of failure.
is_retryable()Check if this outcome represents a potentially retryable failure.
Internal & Generic Methods
- to_dict: Convert to dictionary for serialization or logging.
Usage
Success case:
>>> outcome = AgentRunOutcome(status="success", output="Task completed")
>>> assert outcome.is_success()
Validation failure:
>>> outcome = AgentRunOutcome(
... status="invalid_output",
... error="Output format is invalid",
... error_category="validation"
... )
>>> assert outcome.is_retryable()
Timeout with context:
>>> outcome = AgentRunOutcome(
... status="timeout",
... error="Agent timed out after 30s",
... elapsed_s=30.0,
... agent_name="researcher"
... )Source
View on GitHubpraisonaiagents/run_outcome.py at line 78