From Exception • AI Agent SDK

from_exception: Normalise a raised exception into a canonical terminal outcome.

from_exception

Method

</div>

This is a method of the RunOutcome class in the run_outcome module.

Normalise a raised exception into a canonical terminal outcome.

Maps well-known exception types to their terminal reason. Anything unrecognised is treated as `failed` with a redacted message.

Note on `hard_timeout: the run-level budget is the authoritative source of hard_timeout and is applied explicitly by the caller (see _astart_with_outcome). A bare asyncio.TimeoutError reaching this normaliser is a nested operation timeout (e.g. a handoff/tool that exhausted its own budget while the run budget remained) and is therefore classified as failed — not silently promoted to a run-budget hard_timeout, which would drive the wrong host retry/DLQ decision. Real cooperative cancellation is intercepted and re-raised by the run wrapper (see _astart_with_outcome`) before it reaches this normaliser, so host shutdown is honoured. A supersede/interrupt named error that does surface here is a domain “cancelled” outcome.

Signature

python
def from_exception(exc: BaseException, output: Optional[str]) -> 'RunOutcome'

Parameters

ParamField BaseException

No description available.

ParamField Optional[str]

No description available.

Returns

ResponseField 'RunOutcome'

The result of the operation.

Uses

  • cls

Source

View on GitHub

praisonaiagents/agent/run_outcome.py at line 78