FreeSeries, 5 lessons, 42 min
Tool Calling From Scratch
Write the agent loop by hand: tool contracts, validation, budgets and replay tests.
Written by Eldan.
What you will learn
- Describe a tool as a name, a description and a JSON Schema
- Write a working agent loop in about thirty lines
- Return validation errors the model can recover from
- Bound a run with step, time and token budgets
- Detect repeated calls and stop loops
- Test the loop with a scripted model and no API key
5 lessons, in order
Lesson 1: A tool is a contract
Concept, 5 min
Describe a tool as a name, a description and a JSON Schema, and design it for a model.
Lesson 2: The agent loop in thirty lines
Example, 8 min
Write a working agent loop with a step limit and test it with a scripted model.
Lesson 3: Validate arguments and return errors the model can use
Exercise, 15 min
Write an execute function that validates arguments and turns every failure into a result the model can recover from.
Lesson 4: Budgets, loops and guards
Concept, 7 min
Bound a run with step, time and token budgets, detect repeated calls, and guard tools with side effects.
Lesson 5: Trace every run and test the loop without a model
Check, 7 min
Record a trace for each run and test the loop with a scripted model and no API key.
The Eval Habit, by email
Seven short lessons by email that take one feature of yours to a measured score and a check in CI. One lesson a day, free, no account needed.