Skip to main content
AXON treats failure as a first-class citizen. Unlike traditional programming languages where errors are afterthoughts, AXON’s error handling is deeply integrated into the language design, runtime, and execution model.

Philosophy

Fail Gracefully, Heal AutomaticallyAXON programs don’t just crash — they self-heal through adaptive retry, semantic validation, and failure context injection.
Every error in AXON carries structured diagnostic context and is handled according to a strict severity hierarchy.

The 6-Level Error Hierarchy

Errors are ordered from least to most critical. Each level has specific semantics, recovery strategies, and runtime behavior.

Level 1: ValidationError

Output type doesn’t match declaration

Level 2: ConfidenceError

Confidence score below configured floor

Level 3: AnchorBreachError

Hard constraint anchor violated

Level 4: RefineExhaustedError

Max retry attempts exceeded

Level 5: ModelCallError

LLM API call failed

Level 6: ExecutionTimeoutError

Execution time limit exceeded

Level 1: ValidationError

When It Happens

Raised by the SemanticValidator when a step’s output fails epistemic type checking.

Error Structure

Location: /axon/runtime/runtime_errors.py:119
runtime_errors.py

Recovery Strategy

If refine block configured:
The retry engine re-invokes with:

Level 2: ConfidenceError

When It Happens

Raised when the model’s self-reported confidence falls below the configured threshold.

Error Structure

runtime_errors.py

Recovery Strategy

Increase Depth

Request More Context

Use Tool

Fallback

Design Choice: Low confidence is treated as an error, not a warning. AXON programs must explicitly handle uncertainty.

Level 3: AnchorBreachError

When It Happens

Raised when a hard constraint (anchor) is violated. Anchors represent inviolable rules.
contract_analyzer.axon

Error Structure

runtime_errors.py

Anchor Types

Enforce information quality:
  • NoHallucination — Block unverified claims
  • RequiresCitation — Demand explicit sources
  • AgnosticFallback — Penalize speculation

Recovery Strategy

Anchor breaches always trigger refinement if configured:
On retry, the model receives:
Critical: If refinement exhausted or not configured, AnchorBreachError propagates. Anchors are never ignored.

Level 4: RefineExhaustedError

When It Happens

Raised by the RetryEngine when all retry attempts fail.

Error Structure

Location: /axon/runtime/runtime_errors.py:177
runtime_errors.py

Error Context

Includes all attempt records:

Recovery Strategy

1

on_exhaustion Fallback

2

on_exhaustion Skip

3

Propagate to Caller

Default behavior — error propagates up the stack

Level 5: ModelCallError

When It Happens

Raised when the LLM API call itself fails (not the model’s output). Common Causes:
  • Network timeout
  • Rate limiting (HTTP 429)
  • Invalid API key (HTTP 401)
  • Model overload (HTTP 503)
  • Malformed request

Error Structure

runtime_errors.py

Recovery Strategy

Most backends have built-in retry with exponential backoff:
anthropic.py

Level 6: ExecutionTimeoutError

When It Happens

Raised when execution exceeds configured time limit.

Error Structure

runtime_errors.py

Recovery Strategy

Increase Timeout

Reduce Scope

Async Execution (Planned)

Phase 6: Background execution with callbacks

Early Termination

Flow terminates immediately, returns partial results
Timeout errors cannot be refined — they indicate infrastructure issues, not semantic failures.

Self-Healing Mechanism

AXON’s adaptive retry engine creates a closed feedback loop between the model and runtime.

How It Works

1

Step Execution

Model produces output for a step
2

Validation

Runtime checks type, confidence, anchors
3

Failure Detected

ValidationError, ConfidenceError, or AnchorBreachError
4

Failure Context Injection

Exact error details injected into next prompt:
5

Adaptive Retry

Model learns from mistake and tries again
6

Backoff Strategy

Optional delay between attempts:
  • none: Immediate retry
  • linear: 1s, 2s, 3s, …
  • exponential: 0.5s, 1s, 2s, 4s, 8s, …

Configuration

Full refinement config

Guarantees

Strict Boundaries: Self-healing respects max_attempts. If the model fails to heal within limits, AXON raises RefineExhaustedErrorno infinite loops.
Anchor Dependency: Healing effectiveness depends on anchor precision. Clear, logical anchors enable successful recovery. Ambiguous anchors may cause syntactic fixes without semantic improvement.

Tracing and Diagnostics

Every error is automatically traced with full context.

Trace Events

program.trace.json

View Traces

Outputs human-readable execution timeline with errors highlighted.

Error Propagation

Errors propagate up the call stack unless handled:
Exit Codes:
  • 0 — Success
  • 1 — Validation/Confidence/Anchor error
  • 2 — Refine exhausted
  • 3 — Model call failed
  • 4 — Execution timeout
  • 5 — Compilation error

Best Practices

Don’t rely on default error propagation:
Vague anchors lead to poor self-healing:anchor Reasonable { /* vague */ }
anchor RequiresCitation { require: source_citation }
Too high = constant failures, too low = unreliable:
  • Exploratory: 0.6
  • Standard: 0.75
  • High-stakes: 0.85+
Save traces for post-mortem analysis:
Infrastructure errors need different handling than semantic errors:

Comparison with Traditional Error Handling


Next Steps

Cognitive Primitives

Learn about refine, anchor, validate

Type System

Understand ValidationError triggers

Compilation Pipeline

See where errors are detected

Runtime Reference

Deep dive into executor and validator