stamina

Production-grade retry library for Python by Hynek Schlawack (attrs, structlog author). Wraps tenacity with opinionated defaults suitable for production use: exponential backoff with jitter, structured logging of retry attempts, async support, and Prometheus metrics integration. @stamina.retry decorator and stamina.retry_context() context manager. Designed with the lesson that naive retry implementations cause cascading failures in production.

Evaluated Mar 06, 2026 (0d ago) v23.x+
Homepage ↗ Repo ↗ Developer Tools retry python resilience async sync exponential-backoff circuit-breaker hynek
⚙ Agent Friendliness
68
/ 100
Can an agent use this?
🔒 Security
84
/ 100
Is it safe for agents?
⚡ Reliability
85
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
86
Error Messages
88
Auth Simplicity
95
Rate Limits
95

🔒 Security

TLS Enforcement
85
Auth Strength
82
Scope Granularity
80
Dep. Hygiene
88
Secret Handling
85

Retry library — no direct security surface. Retrying auth failures can expose timing information; exclude auth errors from retry scope. Maintained by trusted Python community member.

⚡ Reliability

Uptime/SLA
85
Version Stability
83
Breaking Changes
80
Error Recovery
92
AF Security Reliability

Best When

You want production-ready retry behavior with sensible defaults, structured logging, and async support without tuning tenacity internals.

Avoid When

You need fine-grained retry conditions that stamina's opinionated wrapper doesn't expose — use tenacity directly for complex retry logic.

Use Cases

  • Retry agent LLM API calls on transient failures (rate limits, timeouts) with production-safe exponential backoff and jitter
  • Add structured retry logging to agent HTTP clients — stamina logs each retry attempt with attempt number, wait time, and exception details
  • Use stamina with async agent code — @stamina.retry works on both sync and async functions natively
  • Integrate stamina's Prometheus metrics to monitor agent retry rates and identify flaky external dependencies
  • Use stamina.retry_context() for more control in agent code that needs to handle retry state mid-loop

Not For

  • Circuit breaker patterns — stamina handles retry but not circuit breaking; use pybreaker or resilience4j for circuit breaker
  • Complex conditional retry logic — tenacity directly offers more configuration options when stamina's opinionated defaults don't fit
  • Python 2 or Python <3.8 — stamina requires Python 3.8+

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

Retry library — no authentication.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

MIT license. Maintained by Hynek Schlawack.

Agent Metadata

Pagination
none
Idempotent
Partial
Retry Guidance
Documented

Known Gotchas

  • stamina retries on ANY exception by default — non-retryable exceptions (authentication errors, validation errors) should be excluded via on= parameter to avoid unnecessary retries
  • stamina is testing-aware: set STAMINA_TESTING=true environment variable to disable waiting in tests — forgetting this makes test suites with retry code very slow
  • Async functions decorated with @stamina.retry must be awaited — the decorator returns a coroutine for async functions; sync usage of an async-stamina-decorated function doesn't work
  • stamina's default max_attempts=10 with exponential backoff can result in very long total retry time — configure max_wait and timeout to bound total retry duration for agent SLAs
  • Prometheus metrics require prometheus_client installed — stamina checks for it at import time and silently disables metrics if not available without warning
  • stamina.retry_context() is a generator — it must be used in a for loop pattern, not as a regular context manager; incorrect usage causes StopIteration immediately

Alternatives

Full Evaluation Report

Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for stamina.

$99

Scores are editorial opinions as of 2026-03-06.

5208
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered