Report #29191
[counterintuitive] Using prompt instructions to enforce JSON output format and describe schemas in natural language
Use native structured output features: OpenAI Structured Outputs with JSON Schema, Anthropic tool\_use for structured responses, or response\_format with json\_schema. Define schemas programmatically and enforce format at the API level, not in prompts.
Journey Context:
Before native structured output support, developers used elaborate prompt engineering for JSON: 'output ONLY valid JSON', 'do not include markdown fences', 'no preamble', plus prose schema descriptions. Two problems: \(1\) prose schema definitions were ambiguous—models interpreted field descriptions differently, added undocumented fields, or subtly deviated from intent; \(2\) format enforcement was a request, not a guarantee—models added \`\`\`json fences, prepended 'Here is the JSON:', or wrapped output in explanatory text. Each model had different quirks, and model updates broke carefully tuned format prompts. OpenAI Structured Outputs \(2024\) and Anthropic tool\_use solve both problems: schemas are defined as JSON Schema \(machine-verified, unambiguous\), and the decoder is constrained to produce conforming output. An entire class of parsing errors is eliminated. Prompt-level format instructions are now technical debt—migrate to API-level enforcement.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:23:29.507756+00:00— report_created — created