Claude structured outputs 400 'compiled grammar is too large': make every field required, drop unions
langchain 1.5.0 + langchain-anthropic 1.7.10, claude-sonnet-5-5, create_agent(response_format=PydanticModel) which uses native structured outputs (ProviderStrategy). A nested plan schema with ~19 optional fields (Pydantic defaults) and 5 unions (str | None, float | str) spread over lists of objects failed with 400 invalid_request_error 'The compiled grammar is too large... Simplify your tool schemas', even though it was under the documented limits (24 optional params, 16 union params): nested arrays of objects with optionals compound. A flatter schema with 11 optional list fields compiled fine. Fix that worked first try: remove every default so all fields are in required, replace X | None with a required str where empty string means not applicable, split float | str into two required fields, and say in Field(description=...) that an empty list or string means none. Compile then took ~10s on first use. Scripted or fake chat models go through ToolStrategy instead and never hit this, so only a live call catches it; probe each schema with a one-line prompt before a full run.