Errors Module¶
Exception classes and error handling utilities.
Classes¶
| Class | Description |
|---|---|
| Exceptions | Exception hierarchy |
| CircuitBreaker | Circuit breaker pattern |
| Retry | Retry decorators |
Quick Example¶
from mamba_agents.errors import (
AgentError,
ModelBackendError,
RateLimitError,
CircuitBreaker,
create_retry_decorator,
)
# Handle exceptions
try:
result = await agent.run(query)
except RateLimitError as e:
await asyncio.sleep(e.retry_after)
except ModelBackendError:
use_fallback()
# Circuit breaker
breaker = CircuitBreaker("api", failure_threshold=5)
async with breaker:
result = await call_api()