Sync and Async Parity: Circuit breaker protection now applies uniformly to both sync and async tool execution paths. Previously, async calls bypassed circuit breaker checks.
This tool-level circuit breaker is separate from the new LLM idle-timeout circuit breaker, which protects against LLM provider stalls during model calls.
Per-agent scoping: breakers are now keyed per agent instance (
tool_{id(self)}_{function_name}), so two agents that expose same-named tools (e.g. search) no longer share one breaker — one agent’s failures can’t degrade the other. Per-agent breakers are auto-pruned from the registry when the Agent is garbage-collected (via weakref.finalize), so a reused instance id can’t inherit a stale OPEN breaker — agent.close() / aclose() merely reclaims that space earlier.Quick Start
1
Works by default
Circuit breaker protection is automatically enabled for every tool call with zero configuration needed.
2
Detect open circuit
When a tool fails 5 times consecutively, subsequent calls return an error dictionary instead of calling the tool.
3
Tune or reset
Customize circuit breaker behavior or reset all breakers between test runs.
How It Works
Configuration Options
What Does NOT Trip the Breaker
Circuit breakers ignore certain error types to avoid false positives:- Approval denied errors - User permission issues don’t indicate tool problems
- Permission denied errors - Access control failures aren’t tool failures
- Approval process errors - User workflow issues shouldn’t trigger circuit breaking
Lifecycle
Per-agent breakers are pruned from the global registry automatically when theAgent is garbage-collected — a weakref.finalize callback is registered when each breaker is created. This closes the CPython id()-reuse window without requiring agent.close() / agent.aclose() to be called explicitly.
Calling agent.close() / agent.aclose() still triggers the same cleanup earlier and deterministically — recommended when you know the agent is done and want registry space reclaimed immediately.
Common Patterns
- Observability
- Custom Config Per Tool
- Global Reset
Monitor circuit breaker health and statistics for debugging.
Best Practices
Don't disable in production
Don't disable in production
Circuit breakers prevent cascading failures and protect system stability. Keep them enabled in production environments to ensure reliable agent operation.
Monitor circuit breaker stats
Monitor circuit breaker stats
Track circuit breaker statistics in your monitoring systems. Frequent openings indicate underlying tool reliability issues that need attention.
Reset between test runs
Reset between test runs
Per-agent breakers are auto-pruned when the
Agent is collected (via weakref.finalize). Explicit agent.close() reclaims registry space immediately. reset_all_circuit_breakers() remains the sledgehammer for global tests that need a clean slate regardless of GC timing.Surface circuit_open to users
Surface circuit_open to users
When handling
circuit_open: true responses, provide clear user feedback about temporary tool unavailability and suggest retry timeframes or alternative approaches.Related
Model Failover
Automatic LLM provider switching
Error Handling
Comprehensive error handling strategies

