Lesson 06.01 · Phase 06 · Planning & Reasoning
Chain-of-thought for actions
Ask the model to write one line of reasoning before each tool call: the constraints, and the choice. Then don't trust that line. Check it against the action, and check the action against the constraints.
Learning objectives
- Add a "Thought:" line before every tool call through the system prompt, and parse it out of the model's messages.
- Check the thought against the action (does the reasoning name the thing the call acts on?) and the action against the task's constraints, in code.
- Keep thoughts out of the user's reply, and measure what they cost.
- Run a live experiment comparing acting directly with thinking first, instead of assuming the answer.
"Book the cheapest Lyon–Paris train arriving before 10:00." The search returns three trains. The cheapest, T3 at 39 euros, arrives at 10:25. A model that goes straight from the search result to book() often grabs the cheapest one, because "cheapest" is the most salient word in the request. The constraint is right there; it just wasn't applied.
Loading the full lesson…