⌨️MAX_STRUCTURED_OUTPUT_RETRIES
Also known as MAX_STRUCTURED_OUTPUT_RETRIES environment variable
It sets how many tries the model gets to match a schema.
Think of it like
It is like you give a child five tries to fill in a form right.
Example
Jack's job waits a long time when the model keeps missing his schema. He sets this to 2, so it fails fast and he can fix the schema.
Why it matters
Each retry costs time and tokens. A cap stops a bad schema from burning both.
Definition
Example code
bash
export MAX_STRUCTURED_OUTPUT_RETRIES=2
claude -p --json-schema schema.json "List the open bugs"Common mistake
Key takeaways
- 1Default 5. One try, four retries.
- 2Print mode. With --json-schema.
- 3Then it fails. No valid output.