Validation retries for LLM output: Instructor max_retries and Tenacity
Answer: Instructor treats bad output as a validation error with a clear message the system can use to self-correct. With the max_retries parameter you set the number of times you can reask the model to correct the output.
Two settings share one name
OpenAI(max_retries=2)orAnthropic(max_retries=2)sets transport retries at the SDK level after the initial HTTP request.client.create(max_retries=2, ...)sets validation retries at the Instructor level: two retries mean at most three SDK calls.- Reasking covers Pydantic validation errors and JSON decoding errors. An exhausted SDK rate-limit, connection or server error is not restarted automatically; it is wrapped in
InstructorRetryException.
Tenacity
Tenacity adds retry logic with decorators such as @retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10)).
See also
- ao-retries-exponential-backoff
- ao-structured-openai-structured-outputs
- ao-structured-gemini-json-schema
- ao-structured-json-schema-composition
Claims
- id: C1 claim: max_retries sets reasks. source: S1 evidence: "you can use the
max_retriesparameter to set the number of times"
- id: C2 claim: Validation retries make at most three calls. source: S2 evidence: "after the first extraction attempt: at most three SDK calls"
- id: C3 claim: Tenacity stops after a set number of attempts. source: S3 evidence: "@retry(stop=stop_after_attempt(7))"
Sources
- [S1] Validation and reasking (Instructor docs). 567-labs/instructor (GitHub). https://github.com/567-labs/instructor/blob/main/docs/concepts/reask_validation.md . License: MIT. Accessed 2026-11-16.
- [S2] Retrying (Instructor docs). 567-labs/instructor (GitHub). https://github.com/567-labs/instructor/blob/main/docs/concepts/retrying.md . License: MIT. Accessed 2026-11-16.
- [S3] Tenacity documentation. jd/tenacity (GitHub). https://github.com/jd/tenacity/blob/main/doc/source/index.rst . License: Apache-2.0. Accessed 2026-11-16.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: 567-labs/instructor (GitHub), Validation and reasking (Instructor docs), MIT (https://raw.githubusercontent.com/567-labs/instructor/main/LICENSE). Copyright (c) 2023 Jason Liu; 567-labs/instructor (GitHub), Retrying (Instructor docs), MIT (https://raw.githubusercontent.com/567-labs/instructor/main/LICENSE). Copyright (c) 2023 Jason Liu; jd/tenacity (GitHub), Tenacity documentation, Apache-2.0 (https://raw.githubusercontent.com/jd/tenacity/main/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: 567-labs/instructor (GitHub), Validation and reasking (Instructor docs), MIT (https://raw.githubusercontent.com/567-labs/instructor/main/LICENSE). Copyright (c) 2023 Jason Liu; 567-labs/instructor (GitHub), Retrying (Instructor docs), MIT (https://raw.githubusercontent.com/567-labs/instructor/main/LICENSE). Copyright (c) 2023 Jason Liu; jd/tenacity (GitHub), Tenacity documentation, Apache-2.0 (https://raw.githubusercontent.com/jd/tenacity/main/LICENSE).
Cite this
iinventedlight. 2026. "Validation retries for LLM output: Instructor max_retries and Tenacity." iinventedlight Library, iil:note:4pf7e0qz, version of 2026-11-16. https://iinventedlight.com/library/notes/ao-structured-instructor-validation-retries/. License: CC-BY-4.0.
@misc{iil_note_4pf7e0qz,
author = {{iinventedlight}},
title = {{Validation retries for LLM output: Instructor max\_retries and Tenacity}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-16},
url = {https://iinventedlight.com/library/notes/ao-structured-instructor-validation-retries/},
note = {Permanent ID iil:note:4pf7e0qz. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/ao-structured-instructor-validation-retries.md.