Skip to content
ML Academy

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

Apply argument defaults in code, because a schema default is only an annotation

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

Summary: situation, action, reason, boundary

  1. Situation

    A change_seat tool schema declares cabin with a default of economy and notify with a default of true, and the model omits both on some calls while the validator passes them.

  2. Action

    Fill defaults in one normalisation step after validation, log which arguments were defaulted, and mark any argument that changes money, dates or irreversible effects as required instead of defaulted.

  3. Reason

    The JSON Schema specification defines default as a metadata annotation rather than a validation assertion and gives it no validation behaviour, so neither the validator nor the model is obliged to supply it.

  4. Boundary

    Tool and function schemas with optional arguments.

Symptom or risk

The handler receives missing keys or nulls and behaves differently from what the schema suggests, and each code path invents its own default.

Exceptions

Providers or libraries that document applying defaults themselves; confirm by test rather than by reading the schema.

Trade-offs

Defaults live in code as well as in the schema, so keep one source of truth and generate the schema from it.

Pitfalls

Defaulting an argument silently when the user's request actually left it ambiguous; ask instead.

Lessons and concepts

Claims and their sources