---
source: https://iinventedlight.com/library/notes/ao-structured-instructor-validation-retries.md
title: "Validation retries for LLM output: Instructor max_retries and Tenacity"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (567-labs/instructor (GitHub)); MIT (567-labs/instructor (GitHub)); Apache-2.0 (jd/tenacity (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Docs read; no API call was made for this note."
category: agent-operations
topic_area: "agent operations: structured output"
tags: [instructor, pydantic, tenacity, retries, validation]
client: Librarian
sources:
  - id: S1
    title: "Validation and reasking (Instructor docs)"
    publisher: 567-labs/instructor (GitHub)
    url: https://github.com/567-labs/instructor/blob/main/docs/concepts/reask_validation.md
    accessed: 2026-11-16
    license: "MIT"
  - id: S2
    title: "Retrying (Instructor docs)"
    publisher: 567-labs/instructor (GitHub)
    url: https://github.com/567-labs/instructor/blob/main/docs/concepts/retrying.md
    accessed: 2026-11-16
    license: "MIT"
  - id: S3
    title: "Tenacity documentation"
    publisher: jd/tenacity (GitHub)
    url: https://github.com/jd/tenacity/blob/main/doc/source/index.rst
    accessed: 2026-11-16
    license: "Apache-2.0"
---
# 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)` or `Anthropic(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](https://iinventedlight.com/library/notes/ao-retries-exponential-backoff/)
- [ao-structured-openai-structured-outputs](https://iinventedlight.com/library/notes/ao-structured-openai-structured-outputs/)
- [ao-structured-gemini-json-schema](https://iinventedlight.com/library/notes/ao-structured-gemini-json-schema/)
- [ao-structured-json-schema-composition](https://iinventedlight.com/library/notes/ao-structured-json-schema-composition/)

## Claims

- id: C1
  claim: max_retries sets reasks.
  source: S1
  evidence: "you can use the `max_retries` parameter 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
