Structured Output and Defensive Parsing
atomic-noteD6 · 11%Section: D6 Prompt & Context EngineeringUpdated 2026-11-15
Use constrained structured outputs or schema validation when downstream software requires typed data, and still validate semantic correctness.
Blueprint area: D6 - Prompt and Context Engineering MOC (official domain weight 11.0%).
Engineering principles
- When supported,
output_config.formatwith JSON schema constrains output shape; strict tool use can constrain tool inputs. - Schema compliance guarantees types/shape within supported constraints, not that extracted values refer to the right entity or are true.
- Handle refusal, truncation, interrupted streaming, tool error and unsupported-schema cases separately.
- Validate business invariants, referential integrity, field provenance and authorization after parsing.
Failure modes
JSON.parsesuccess is not a data-quality metric.- Changing the schema or tool set can change caching and first-request latency.
Check your understanding
- ☐ Test valid JSON with deliberately wrong customer-to-order mapping.
- ☐ Reject output that violates domain constraints despite a successful parse.
Related knowledge
System Prompts XML and Few Shot · Messages API Contract · Exam Blueprint and Coverage
Evidence and verification
- Provenance: author-written engineering synthesis aligned to exam guide objectives; this is not a transcript or hidden Skilljar lesson.
- Primary references:
- Check currency: model options, pricing, API flags, release-specific behavior and runtime permissions can change after the source was read. See Source Register.