Typed termination subtypes for agent-loop runs.
Every run ends with exactly one termination. Normal completions use :stop;
everything else is an error subtype carrying enough context (usage, cost,
duration) to drive retries and observability.
Inspired by the Claude Agent SDK's typed termination subtypes — they keep accounting uniform across happy and sad paths.
Subtypes
:stop— model returned text with no tool calls.:error_max_turns— iteration cap reached.:error_max_budget_usd— cost ceiling tripped.:error_during_execution— unrecoverable tool / provider error.:error_max_structured_output_retries— repair budget exhausted.:error_consecutive_mistakes— mistake counter threshold hit.:error_halted— hook or tool returned:halt.:error_compaction_failed— context compaction failed.
Summary
Functions
All known termination subtypes.
Categorise a termination for retry classification. Returns one of:
:retryable, :capacity, :fatal.
Is this an error termination?
Is this a successful termination?
Types
Functions
@spec all() :: [subtype()]
All known termination subtypes.
@spec category(subtype()) :: :success | :retryable | :capacity | :fatal
Categorise a termination for retry classification. Returns one of:
:retryable, :capacity, :fatal.
:retryable— transient; caller may retry on a new run.:capacity— the run hit a configured limit; caller should increase the limit or reduce scope.:fatal— don't retry without operator action.
Is this an error termination?
Is this a successful termination?