Retry Engine
The RetryEngine provides adaptive retry with failure context injection forrefine blocks in AXON programs.
Key Features
- Failure Context Injection — Pass previous error to next attempt
- Configurable Backoff — None, linear, or exponential delays
- Attempt Tracking — Full record of each retry
- Exhaustion Handling — Configurable behavior when all attempts fail
- Trace Integration — Every retry is logged
Configuration
RefineConfig
Implementation
Backoff Strategies
None (Immediate)
Linear
Exponential
Implementation
Failure Context Injection
How It Works
Whenpass_failure_context: true, the previous error is injected into the next attempt’s prompt:
Model Client Integration
TheModelClient.call() method receives the failure context:
Backend Handling
Backends append failure context to the user prompt:Attempt Records
AttemptRecord
RetryResult
Example: Self-Healing Validation
Scenario
A step requires structured output with specific fields, but the model omits one.Attempt 1
Model Output:termination_clause
Attempt 2 (with failure context)
Injected Context:Exhaustion Handling
on_exhaustion: "" (Default - Raise)
RefineExhaustedError when all attempts fail:
on_exhaustion: “skip”
RetryResult(success=False, exhausted=True) without raising:
on_exhaustion: “fallback”
Trace Integration
Every retry is fully traced:Refine Start
Retry Attempts
Example Trace
Configuration Examples
Conservative (Fast Retry)
Aggressive (Deep Healing)
Graceful Degradation
Integration with Executor
The Executor always routes through the RetryEngine:refine blocks go through the engine (with max_attempts=1).
Error Types Handled
The RetryEngine catches all exceptions and treats them as retry-able:ValidationError— Semantic validation failureAnchorBreachError— Anchor constraint violationModelCallError— LLM API failureConfidenceError— Confidence below threshold- Any
Exception— Generic error
Next Steps
Semantic Validator
See what triggers validation failures
Tracer
Understand retry observability
Executor
Review the full execution pipeline
