Anthropic API · api · fg-0477

Structured outputs return 400 'Schema is too complex for compilation' or 'compiled grammar is too large'

If you see The compiled grammar is too large, which would cause performance issues. Simplify your tool schemas or reduce the number of strict tools, the cause and the fix for Anthropic API are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
The compiled grammar is too large, which would cause performance issues. Simplify your tool schemas or reduce the number of strict tools.Schema is too complex for compilation.Each schema looks small, but the request fails once several strict tools are combined
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');
Affected
Claude structured outputs (output_config.format) and strict tool use, as of 2026-10
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun