Skip to content
AI Agents in Go
  • The loop
  • Design
  • Production
  • Run it
  • Providers
  • Findings
  • Glossary
  • The book
  • Work with me

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.

  1. 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
  2. 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
  3. 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.

AI Agents in Go

A code-first guide to building AI agents in Go, by Dayna Blackwell.

© 2026 Dayna Blackwell · RSS feed · What this covers

Not affiliated with or endorsed by Google or the Go project.

The Go gopher was designed by Renée French (CC BY 4.0).

Code excerpts come from the companion code, licensed under Apache 2.0.

Bide, a library for durable agents

Fonts under the SIL Open Font License: Cinzel, Inter, and Space Grotesk.