- Home
- Skills
- Code Quality & Review
- tenacity exception classifier
tenacity exception classifier
Audit and fix dangerous Tenacity retry logic to prevent infinite loops and swallowed exceptions.
$10
Works with the AI Agents you already use
tenacity exception classifier
Example session with this skill installed
Review the retry logic in my service layer. I'm seeing 404 errors causing infinite retry loops and I'm losing the original stack traces.
- Read your context and instructions
- Compiled the tenacity exception classifier
I have completed the audit of your retry logic. I identified 3 critical issues where permanent failures were being retried and root causes were being swallowed by Tenacity's default behavior.
Tenacity Exception Audit Report
| Finding ID | Severity | Location | Issue |
|---|---|---|---|
| EXC-3-4a1b | Critical | services/api_client.py:42 | Retrying on all HTTPStatusError including 404/401 |
| EXC-5-9f2d | High | services/orders.py:112 | Missing reraise=True hiding root cause |
| EXC-1-c3e8 | Critical | gateways/stripe.py:15 | Bare @retry decorator (infinite, no backoff) |
Detailed Findings & Fixes
Finding EXC-3-4a1b: Dangerous HTTP Retries
The current implementation retries on any httpx.HTTPStatusError. This includes 404 Not Found and 401 Unauthorized, which will never succeed on a retry and may trigger security lockouts.
Recommended Fix:
Use a transient-only predicate. I have generated a patch that implements a status-code filter.
# Generated Patch: ./output/patches/EXC-3-4a1b.py
import httpx
from tenacity import retry, retry_if_exception, stop_after_attempt, wait_exponential_jitter
_TRANSIENT_CODES = {408, 429, 500, 502, 503, 504}
def is_transient_http_error(exc: BaseException) -> bool:
if isinstance(exc, httpx.ConnectError):
return True
if isinstance(exc, httpx.HTTPStatusError):
return exc.response.status_code in _TRANSIENT_CODES
return False
@retry(
retry=retry_if_exception(is_transient_http_error),
stop=stop_after_attempt(3),
wait=wait_exponential_jitter(initial=1, max=10),
reraise=True
)
def fetch_data():
...
Next steps
- Review the full report in
./output/tenacity-exception-classifier-report.md. - Apply the specific fixes from
./output/patches/. - Verify that your logging captures the
is_transient_http_errorpredicate logic.
Connects securely to your tools. The creator never sees your data.
About this skill
The problem
Improper retry logic leads to infinite loops, account lockouts from 401/403 errors, and swallowed root causes. Developers often use broad decorators that retry on programming bugs or permanent API failures, wasting resources and masking critical defects.
What it does
- Identifies dangerous bare
@retrydecorators and over-broadExceptioncatches. - Flags incorrect retry behavior on HTTP 4xx errors, authentication failures, and logic errors like
KeyErrororValueError. - Detects hidden root causes where
reraise=Trueis missing from Tenacity configurations. - Generates precise, named transient-error predicates and refactored retry logic tailored to your specific HTTP client and exception hierarchy.
Frameworks & tools
Python, Tenacity, Requests, HTTPX.
Why this beats prompting it yourself
General LLMs often suggest generic retry blocks that don't account for the difference between transient network blips and permanent logic errors. This skill performs a deep static analysis of your project's exception hierarchy to ensure custom exceptions are classified correctly before suggesting a fix.
Use cases
- Auditing a legacy codebase for fragile or unbounded retry loops.
- Hardening API clients against rate limits and authentication failures.
- Debugging
RetryErrorstacks that hide the original exception.
Known limitations
Analysis is read-only and static. It does not execute code, handle non-UTF-8 files, or support Python 2 syntax.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Code Quality & Review.
Static analysis only; no code execution. Skips non-UTF-8 files, Python 2, and large repos over 5,000 files. Requires manual application of generated patches.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 months ago
- Software
Python
Permissions
No special permissions declared or detected