Section
The loop
The loop at the center of every agent, and what happens on each pass through it: the request, the model call, tool calls on the wire, tokens, and cost.
- The agent loop An agent is a model inside a loop, and the loop is plain Go. This page reads the whole loop, about 30 lines, stage by stage, along with the rules that keep it correct.chapters 1, 4, and 5
- Tool calling on the wire What a tool call looks like as JSON on an OpenAI-compatible chat completions API, how a Go client sends tool definitions and reads calls back, and the rules that keep a conversation valid.chapters 4 and 2
- Why Go An agent spends most of its time waiting on a network, running work side by side, and deciding when to stop. Four places where Go’s standard tools did that job in the book’s code, with the numbers, and what Go costs you here.chapters 5, 9, 11, 12, 15, and 16
Start here if you are new to agents. These pages build the parts every agent shares, in the order the loop uses them, and each one points at the runnable code it comes from.