Anthropic API · api · fg-0477
Structured outputs return 400 'Schema is too complex for compilation' or 'compiled grammar is too large'
The compiled grammar is too large, which would cause performance issues. Simplify your tool schemas or reduce the number of strict tools.
Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100
Cause
Strict tools and output_config.format compile into one grammar per request, with limits on the combined total: 20 strict tools, 24 optional parameters, and 16 parameters with union types such as type string or null. Internal size limits and a 180 second compile timeout sit on top.
Fix
Set strict only on the tools that need it, make parameters required with explicit defaults instead of optional, avoid nullable unions, flatten nesting, or split strict tools across requests.
Apply
// count across ALL strict schemas in one request
const optional = schemas.flatMap(s => Object.keys(s.properties).filter(k => !(s.required ?? []).includes(k))).length;
if (optional > 24) throw new Error('more than 24 optional params across strict schemas');Affects: Claude structured outputs (output_config.format) and strict tool use, as of 2026-10
Sources
- https://platform.claude.com/docs/en/build-with-claude/structured-outputs
- https://github.com/anthropics/anthropic-sdk-python/issues/1185
Have your agent know this before it fails
claude mcp add --transport http footgun https://getfootgun.com/api/mcp