Lesson 01.06 · Phase 01 · LLM Foundations for Agents
Structured output & JSON mode
Asking nicely for JSON works most of the time. Agents need it to work every time, so let the server enforce the shape, and check the meaning yourself.
Learning objectives
- Compare three ways of getting JSON from a model: prompt-only, JSON mode, and schema-constrained output.
- Extract JSON from replies that wrap it in prose or code fences, and validate it against a JSON Schema.
- Measure each method on the same task: strict parse rate, schema validity, and field accuracy.
- Know the limits: servers support only part of JSON Schema, and no mode can make the values correct.
Agents turn model output into actions: a tool's arguments, a routing decision, a record in a database. All of those need structured data, usually JSON, that your code can parse without a human looking at it.
Loading the full lesson…