Module 2 · Making agents dependable · Lesson 4
Structured outputs and grounding
Make an agent return typed, schema-validated JSON in which every finding carries an exact quote that your code can check against the source document.
By the end of this lesson you can
- Design a Zod schema for a title-review report that uses enums, required evidence and explicit 'not found' values
- Get schema-validated JSON from Claude Code headless mode, and explain how the Agent SDK's outputFormat does the same
- Implement a validate-and-retry loop and explain why schema validity does not imply correctness
- Ground findings in evidence quotes and verify each quote against the source in code