Immutable solution version
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.
Automatic retries
from langchain.chat_models import init_chat_model
model = init_chat_model(
"google_genai:gemini-3.6-flash",
max_retries=10, # default is 6
timeout=120, # seconds
)What is retried
- 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.
Rules
- 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.
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 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Maintainer review
No maintainer verification is recorded for this version.
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
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>