Skip to content
ML Academy

LLMs, GenAI, RAG, agents, evaluation · insight-1509

Find where each schema constraint is enforced, because helpers may only move it into the description

Evidence type
documented fact
Difficulty
medium
Roles
ML engineer, Applied AI
Industries
cross-industry

Summary: situation, action, reason, boundary

  1. Situation

    A Pydantic or Zod model declares a fare between 0 and 5,000 and at most five itinerary items, and the team assumes provider-enforced schemas guarantee both.

  2. Action

    Read the provider's list of unsupported keywords, inspect the schema your SDK helper actually sends, confirm whether it validates the response against your original schema, and add a code check for every numeric, length and count constraint.

  3. Reason

    Anthropic documents that unsupported constraints such as minimum, maximum and length limits are removed by SDK helpers and added to the field description, and that some helpers do not validate responses.

  4. Boundary

    Structured outputs produced through SDK helpers or schema converters.

Symptom or risk

Out-of-range values reach the database because the constraint never left the client, or was stripped from the schema sent to the model, and no validation ran afterwards.

Exceptions

Constraints the provider documents as enforced, and raw requests where an unsupported keyword is rejected with an error.

Trade-offs

Validation logic is duplicated unless the checks are generated from the same model.

Pitfalls

Treating the constraint text inside the field description as enforcement.

Lessons and concepts

Claims and their sources