Resilience
withRetry
Section titled “withRetry”Retry failed agent runs with exponential backoff:
import { withRetry } from 'agentfootprint/resilience';
const reliable = withRetry(agent, { maxRetries: 3, backoffMs: 1000,});
await reliable.run('Hello');withFallback
Section titled “withFallback”Fall back to a cheaper/faster agent when the primary fails:
import { withFallback } from 'agentfootprint/resilience';
const resilient = withFallback(primaryAgent, cheapAgent);await resilient.run('Hello');Circuit breaker
Section titled “Circuit breaker”Stop calling a failing provider after N consecutive failures:
import { withCircuitBreaker } from 'agentfootprint/resilience';
const guarded = withCircuitBreaker(agent, { threshold: 5, // open after 5 failures resetAfterMs: 30000, // probe after 30s});Provider failover
Section titled “Provider failover”Cross-family failover: Claude, GPT-4o, local Ollama:
import { anthropic, openai, ollama } from 'agentfootprint';import { fallbackProvider } from 'agentfootprint/resilience';
const provider = fallbackProvider([ anthropic('claude-sonnet-4-20250514'), openai('gpt-4o'), ollama('llama3'),]);
const agent = Agent.create({ provider }).build();