Philosophy
Fail Gracefully, Heal AutomaticallyAXON programs don’t just crash — they self-heal through adaptive retry, semantic validation, and failure context injection.
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:119runtime_errors.py
Recovery Strategy
- Automatic Refinement
- Explicit Handling
- Propagate
If The retry engine re-invokes with:
refine block configured: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
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
- Epistemic Anchors
- Logical Anchors
- Safety Anchors
Enforce information quality:
NoHallucination— Block unverified claimsRequiresCitation— Demand explicit sourcesAgnosticFallback— Penalize speculation
Recovery Strategy
Anchor breaches always trigger refinement if configured:Level 4: RefineExhaustedError
When It Happens
Raised by the RetryEngine when all retry attempts fail.Error Structure
Location:
/axon/runtime/runtime_errors.py:177runtime_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
- Automatic Retry (Backend)
- Fallback Backend
- Circuit Breaker (Planned)
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
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 AnchorBreachError4
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 retrylinear: 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 RefineExhaustedError — no 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
Error Propagation
Errors propagate up the call stack unless handled:Exit Codes:
0— Success1— Validation/Confidence/Anchor error2— Refine exhausted3— Model call failed4— Execution timeout5— Compilation error
Best Practices
Always Configure Refinement
Always Configure Refinement
Don’t rely on default error propagation:
Use Precise Anchors
Use Precise Anchors
Vague anchors lead to poor self-healing:❌
✅
anchor Reasonable { /* vague */ }✅
anchor RequiresCitation { require: source_citation }Set Realistic Confidence Thresholds
Set Realistic Confidence Thresholds
Too high = constant failures, too low = unreliable:
- Exploratory: 0.6
- Standard: 0.75
- High-stakes: 0.85+
Monitor Traces in Production
Monitor Traces in Production
Save traces for post-mortem analysis:
Handle Level 5-6 Errors Explicitly
Handle Level 5-6 Errors Explicitly
Infrastructure errors need different handling than semantic errors:
Comparison with Traditional Error Handling
Next Steps
Cognitive Primitives
Learn about
refine, anchor, validateType System
Understand
ValidationError triggersCompilation Pipeline
See where errors are detected
Runtime Reference
Deep dive into executor and validator

