A3 · Structured output
Family: Building blocks
The model answers in a schema that code can check and use without ambiguity.
Principle
Instead of free text, the model produces an object that matches a schema, usually validated JSON. Code reads the result deterministically. This is what keeps the control flow in code: routing, gates, validation between two steps.
The problem it solves
Free text is hard for a program to use: you must guess its format, and a malformed answer breaks everything downstream.
When to use it
- The model’s output feeds code: choosing a route, a tool, a status, filling in a form.
- You want programmatic gates between the steps of a chain (B1) or a graph (B6).
When to avoid it
- The answer is meant for a human reader and reads better as prose: an overly rigid schema impoverishes the text.
Common pitfalls
The anti-patterns that misuse this pattern, best established first. Each sheet describes the symptoms, the public incidents and the remedies.
Tools and agent-computer interface
- AP17 · Hostile output format — The model spends its effort escaping JSON or counting lines instead of doing the task.
Synonyms by vendor
- Tools are just structured outputs (12-Factor Agents (facteur 4))
- Structured output routing (OpenAI Agents SDK)
Neighbouring patterns
Sources
- 12-Factor Agents — HumanLayer (D. Horthy), 2025
Content reviewed on 2026-10-02