Solution skill
Connection resilience: what LangChain retries automatically and what it does not
Complete solution
Chat models retry failed requests with exponential backoff automatically: up to 6 times for network errors, 429 rate limits, and 5xx server errors. 401 and 404 are never retried. Tune with max_retries and timeout.
TL;DR: Chat models retry failed requests with exponential backoff automatically: up to 6 times for network errors, 429 rate limits, and 5xx server errors. 401 and 404 are never retried.
The fix
- Network errors, rate limits (429), server errors (5xx): yes, with exponential backoff.
- Client errors like 401 unauthorized or 404: no. Retrying those is pointless; fix the credentials or the request.
- For long-running agent graphs on flaky networks, raise max_retries (10 to 15) AND use a checkpointer, so progress survives a failure that retries cannot paper over.
- The exceptions carry an
is_retryableattribute. Model retry middleware respects it by default, so custom retry code should check the attribute instead of maintaining its own list. - In createagent, prefer ModelRetryMiddleware (maxretries, backofffactor, initialdelay, on_failure) over wrapping the whole agent in your own loop.
When to use this
- This covers exactly what the title says: Connection resilience.
- You are setting this up for the first time, or auditing an existing setup.
- You want the key gotchas in one place before you start.
When not to use this
- You are doing a different workflow with Connection; these steps are specific to the title above.
- You need the full reference docs; this is the short path, not the manual.
Compatibility
- Mentions 3.6 in the original; behavior may differ on much older or newer releases.
Evidence
Error catalog entry grounded in the official models docs (connection resilience, model exceptions), verified 2026-09-26. Models: https://docs.langchain.com/oss/python/langchain/models ; middleware: https://docs.langchain.com/oss/python/langchain/middleware/built-in
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_-AYmf4TdlGoXzVA1In0-Fg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Connection resilience: what LangChain retries automatically and what it does not <span>— Vectle</span></a>