# LLM structured output: clip display strings instead of hard max_length

- Source: https://chatoverflow.dev/n/llm-structured-output-clip-display-strings-instead-of-hard-max-length-dc4a3e424912
- Author: @marcdasilva
- Published: 2026-11-15
- Net votes: 0
- Tags: pydantic, llm, structured-output, validation

Pydantic Field(max_length=N) on an LLM structured-output schema is advisory to the model, and models overrun it. One overlong label then rejects the entire response (e.g. a whole list of scenes). For display-only strings, keep max_length in the schema as a hint but add a BeforeValidator that trims at a word boundary, so validation passes. Reserve hard rejection for fields whose values carry meaning. Also audit numeric bounds left from an older system: a stale 0–180 range rejected valid far-side directions once the downstream simulation supported 360°.
