Immutable solution version
Structured outputs: "compiled grammar is too large" error needs better documentation and higher limits for complex schem
Complete solution
How to fix 'Structured outputs: "compiled grammar is too large" error needs better documentation and higher limits for complex schem' in Anthropic, straight from the verified resolution in gh:anthropics/anthropic-sdk-python#1185. Root cause plus what to change.
The problem
Issue anthropics/anthropic-sdk-python#1185 (closed, 17 comments): Using Anthropic structured outputs (outputconfig.format with jsonschema), complex but valid JSON schemas trigger a 400: 'The compiled grammar is too large, which would cause performance issues. Simplify your tool schemas or reduce the number of strict tools.' Large enums and deeply nested schemas blow the grammar budget.
The verified resolution
Contributor dtmeadows-ant: the limits behind the error are now documented (strict tools per request, optional/union parameter budgets, compilation timeout) at platform.claude.com structured-outputs docs, and over-limit requests return a descriptive 400. Community workarounds: flatten schemas, reduce enum cardinality, split into two-pass extraction, keep schema JSON under ~10KB.
Rule of thumb
treat the grammar budget as a hard limit - decompose big schemas into chained smaller calls.
Evidence
Asked in gh:anthropics/anthropic-sdk-python#1185 (https://github.com/anthropics/anthropic-sdk-python/issues/1185): Structured outputs: "compiled grammar is too large" error needs better documentation and higher limits for complex schem. The issue report: Issue anthropics/anthropic-sdk-python#1185 (closed, 17 comments): Using Anthropic structured outputs (outputconfig.format with jsonschema), complex but valid JSON schemas trigger a 400: 'The compiled grammar is too large, which would cause performance issues. Simplify your tool schemas or reduce the number of strict tools.' Large enums and deeply nested schemas blow the grammar budget. The verified answer: Contributor dtmeadows-ant: the limits behind the error are now documented (strict tools per request, optional/union parameter budgets, compilation timeout) at platform.claude.com structured-outputs docs, and over-limit requests return a descriptive 400. Community workarounds: flatten schemas, reduce enum cardinality, split into two-pass extraction, keep schema JSON under ~10KB. Lesson: treat the grammar budget as a hard limit - decompose big schemas into chained smaller calls.
By @issueatlas · Version 1 · Exact version
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_kvWk1JpE2jBtHKefrHRkOw" 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">Structured outputs: "compiled grammar is too large" error needs better documentation and higher limits for complex schem <span>— Vectle</span></a>