Skip to content
Claude Certified Developer – Foundations (CCDV-F) Exam Prep

Lesson 16 of 25 · 6 min

x
16/25

Output Handling

Video lesson: CCDV-F 16/25: Output Handling (Domain 6, 2.6%)

Official scope (Exam Guide v1.0): structured output, response validation, defensive parsing, skepticism toward confident output.

Getting structure

MechanismHowGuarantee
Structured outputs (JSON)output_config.format with type: "json_schema"Response text is valid JSON matching the schema
Strict tool usestrict: true on a toolTool inputs conform to the schema

Both can be combined. Prompting for JSON alone asks; it does not guarantee. Prefill is not accepted on newer models.

What is not guaranteed

  • Truncation: max_tokens can cut JSON off. Check stop_reason first.
  • Refusal: a 200 whose text may not match the schema.
  • Enum case can vary; compare case-insensitively.
  • Unsupported constraints (minimum/maximum, minLength/maxLength, recursive schemas) are not enforced; validate client-side. Every object needs additionalProperties: false.
  • First request with a new schema adds grammar-compile latency; grammars are cached for 24 hours.

Three validation layers (design guidance)

  1. Syntax and schema (parse, types, required fields).
  2. Business rules (ranges, cross-field checks, permitted values, ids that exist).
  3. Semantic / factual checks (evals, spot checks, cross-checks against sources).

Defensive parsing (design guidance)

Parse inside error handling; tolerate unexpected or extra fields where safe; validate types and ranges; never evaluate model text as code; accumulate the full stream before parsing; when validation fails, decide per case: retry with the error fed back (capped), safe default, human review, or fail loudly.

Sanitise before render or execute (design guidance)

Model output is untrusted input to the next component: escape for HTML, parameterise SQL, never pass to a shell or eval without checks.

Skepticism toward confident output (verified mitigations)

Fluent, certain-sounding text is not evidence. Allow "I don't know"; ask for direct quotes or citations and retract claims without support; restrict answers to supplied documents; use best-of-N consistency checks; verify high-stakes claims against a source. Design nullable fields and an "other"/"unclear" enum value so the model is not forced to invent.

Exam traps

  • "Structured outputs guarantee correct data."
  • Parsing without checking stop_reason.
  • Relying on minimum in the schema to enforce ranges.
  • Rendering model HTML directly.
  • Unbounded validation retries.

References

  1. Structured outputs — checked Oct 16, 2026
  2. Define tools (strict) — checked Oct 16, 2026
  3. Handling stop reasons — checked Oct 16, 2026
  4. Reduce hallucinations — checked Oct 16, 2026
  5. Citations — checked Oct 16, 2026

Check your understanding

  • Valid JSON with a wrong customer id. Which layer missed it?Show answer

    Answer

    Business-rule or semantic validation.
  • Structured output ends mid-object. What to check?Show answer

    Answer

    stop_reason (max_tokens).
  • Model text inserted straight into a web page. Risk and fix?Show answer

    Answer

    Markup/script injection; escape or sanitise.
  • Model states a precise figure with no source. Response?Show answer

    Answer

    Ask for a quote or citation, or verify; allow "I don't know".
Previous

Progress is saved in this browser.

Next Lesson