Skip to main content

Crate brainwires_call_policy

Crate brainwires_call_policy 

Source
Expand description

Provider-layer resilience middleware for the Brainwires Agent Framework.

Wraps any brainwires_core::Provider with composable decorators:

Decorators wrap Arc<dyn Provider> and return Arc<dyn Provider>, so they compose freely. Typical stacking (outermost first):

CircuitBreaker → Retry → Budget → base Provider

Structs§

BudgetConfig
Caps to enforce on a single BudgetGuard.
BudgetGuard
Shared atomic budget counters.
BudgetProvider
A Provider decorator that enforces a BudgetGuard around every call.
CacheKey
Key used to address a cached response.
CachedProvider
A Provider decorator that deduplicates identical chat() calls.
CachedResponse
Wire representation of a cached response, suitable for JSON storage.
CircuitBreakerConfig
Circuit-breaker configuration.
CircuitBreakerProvider
Circuit-breaker decorator around any Provider.
MemoryCache
In-memory cache — the default backend. Cheap to Arc-clone.
RetryPolicy
Configuration for retry behavior.
RetryProvider
A Provider decorator that retries transient failures with exponential backoff and optional jitter.

Enums§

CircuitState
Circuit-breaker state for a single provider/model key.
ErrorClass
Coarse error classification used by retry and circuit-breaker logic.
ResilienceError
Errors surfaced by resilience decorators.

Traits§

CacheBackend
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::Error by string inspection.