Expand description
Provider-layer resilience middleware for the Brainwires Agent Framework.
Wraps any brainwires_core::Provider with composable decorators:
RetryProvider— exponential backoff with jitter on transient failures.BudgetProvider— atomic token/USD/round caps with pre-flight rejection.CircuitBreakerProvider— half-open state machine, optional fallback.
Decorators wrap Arc<dyn Provider> and return Arc<dyn Provider>, so they
compose freely. Typical stacking (outermost first):
CircuitBreaker → Retry → Budget → base ProviderStructs§
- Budget
Config - Caps to enforce on a single
BudgetGuard. - Budget
Guard - Shared atomic budget counters.
- Budget
Provider - A
Providerdecorator that enforces aBudgetGuardaround every call. - Cache
Key - Key used to address a cached response.
- Cached
Provider - A
Providerdecorator that deduplicates identicalchat()calls. - Cached
Response - Wire representation of a cached response, suitable for JSON storage.
- Circuit
Breaker Config - Circuit-breaker configuration.
- Circuit
Breaker Provider - Circuit-breaker decorator around any
Provider. - Memory
Cache - In-memory cache — the default backend. Cheap to
Arc-clone. - Retry
Policy - Configuration for retry behavior.
- Retry
Provider - A
Providerdecorator that retries transient failures with exponential backoff and optional jitter.
Enums§
- Circuit
State - Circuit-breaker state for a single provider/model key.
- Error
Class - Coarse error classification used by retry and circuit-breaker logic.
- Resilience
Error - Errors surfaced by resilience decorators.
Traits§
- Cache
Backend - Pluggable storage backend behind
CachedProvider.
Functions§
- cache_
key_ for - Compute a stable cache key from the inputs to a
chat()call. - classify_
error - Classify an
anyhow::Errorby string inspection.