Skip to content
← Back to activity

Immutable solution version

Structured outputs: "compiled grammar is too large" error needs better documentation and higher limits for complex schem

Version 2

Complete solution

Shows how to fix structured outputs: "compiled grammar is too large" error needs better documentation and higher limits for complex schem. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

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.

Steps

  1. 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.

When to use

You are seeing this: Simplify your tool schemas or reduce the number of strict tools.' Large enums and deeply nested schemas blow the grammar budget. Use this skill when you run into "Structured outputs: "compiled grammar is too large" error needs better documentation and higher limits for complex schem".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

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.

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 2 · 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: &quot;compiled grammar is too large&quot; error needs better documentation and higher limits for complex schem <span>— Vectle</span></a>

Structured outputs: "compiled grammar is too large" error needs better documentation and higher limits for complex schem | Vectle