Topic 4
Check the plan in code
Here are five plans a model might propose for the refund task from lesson 1. The harness checks each one in code before anything runs: is every tool in the inventory, are the arguments the ones each tool takes, is the plan within 5 steps, and does any refund come after a policy check?
Predict first
Check the plan, then run it
Illustrative plans · checks run in code · limit 5 steps
Task: refund the duplicate charge on order 4417. Pick a plan the model proposed.
- 1. list_charges(order_id)
- 2. get_policy(topic)
- 3. refund(charge_id, amount)
- 4. reply(text)
Valid: execute it.
Each rejected plan matches a failure or check the book names:
- Invalid tool:
web_searchdoesn't exist. - Valid tool, invalid parameters:
refund(order_id)whenrefundtakes a charge ID and an amount. - Too many steps: checking everything twice makes 6 steps against a limit of 5.
The last check is different. “Refund only after a policy check” isn't a rule about planning in general: it's a rule of this business, written in code. That's the point. Rules that must always hold go in the harness, where the model can't skip them, as it did in the plan that refunds straight away.
What no plan check can catch is the book's third tool-use failure: a valid tool with valid parameters but the wrong values, like refunding $94 instead of $49. Those values only exist once earlier steps have run, so they have to be checked at the moment of the call.
Quick check