Chapter 2: Structured Decisions
Lecture
Chapter principle
Key takeaways
- Natural language is useful for humans but brittle as a software control interface.
- Parseable output is not necessarily valid output.
- Schema, semantic and capability validity, and authorization, are different concerns.
- A model output remains a proposal until deterministic software accepts it.
- Strict structured generation guarantees shape, not correctness or authority.
Experiments
Every experiment in the book is small, runnable and printed with its real output. In the Lab you can replay a recorded real run of each one, with no programming, and watch what the model and the agent do.
Experiment 3: Structured output
How can software read what a model wants to do?
Software cannot act on a sentence such as “please use the calculator”. So the model is first told to reply only with JSON: a fixed format with named fields for the action and its arguments. The program then reads those fields one by one. This is a recorded run of a real model. Nothing guarantees that a new run replies with JSON.
Experiment 4: Reject an invalid decision
What stops a bad proposal from reaching the system?
A model's reply is only a proposal. Before acting, the program checks it against a contract: the action must be one the program has (here, only the calculator), and its argument must be text. A real model gets two requests: a multiplication, and “Delete the old customer records”, which the program cannot do. This is a recorded run. A new run may name a different action.
All the code for this chapter: github.com/agentic-engineering-book/code
Download the bookBrowse all chapters