
Building AI Agents in Go: From the Agent Loop to Production
Author(s): Dayna Blackwell (Author)
- Publisher: Packt Publishing
- Publication Date: November 27, 2026
- Edition: 1st
- Language: English
- Print length: 786 pages
- ISBN-10: 1809310865
- ISBN-13: 9781809310866
Book Description
Build reliable AI agents in Go from scratch, progressing from a simple agent loop to production systems with tool calling, testing, security, and recovery.
Key Features
- Build a complete AI agent in Go from scratch, using the standard library before adding frameworks
- Develop a crash-triage agent and evaluate its performance against 32 reproducible tasks
- Create production-ready agents with secure tools, human approval, cost controls, and crash recovery
- Purchase of the print or Kindle book includes a free PDF eBook
Book Description
Build AI agents that do more than call a language model. Learn to design the Go harness that controls model requests, executes tools, manages context, and handles failures. Starting with a simple agent loop, this hands-on guide takes you through building a complete agent from scratch and preparing it for production.
You'll begin with a testable agent loop before connecting to a real model API. Using Go's standard library, you'll implement HTTP clients, streaming responses, structured tool calling, and concurrency. You'll then build an agent that investigates crashes in a Go web service, groups related reports, identifies root causes, writes reproducer tests, and proposes fixes.
The book takes an evidence-driven approach, measuring agent performance against 32 tasks with hidden tests. You'll explore MCP integration, context management, parallel execution, and framework trade-offs through reproducible experiments. You'll also implement retries, sandboxing, human approval, spending limits, evaluation workflows, and durable state for crash recovery.
By the end, you'll have built a production-oriented crash-triage agent that runs as a CLI or service, handles concurrent investigations, survives restarts, and verifies fixes before reporting them.
What you will learn
- Build an agent loop and integrate language model APIs in Go
- Implement tool calling, JSON schemas, and streaming responses
- Develop an agent that diagnoses crashes and verifies code fixes
- Manage context windows, tokens, and concurrent tool execution
- Integrate external tools and services using MCP
- Evaluate agent reliability with reproducible tests and metrics
- Secure tool execution with sandboxing and human approval
- Implement retries, cost controls, and crash-safe recovery
Who this book is for
Go developers, backend engineers, and software engineers who want to build AI agents from scratch and deploy reliable, tool-using applications. This book is ideal for developers new to LLMs and agentic AI, as well as Python or TypeScript agent developers moving to Go. Familiarity with Go structs, interfaces, errors, and packages is required. No prior experience with AI agents, machine learning, or LLM development is necessary.
Table of Contents
- What an agent is
- Talking to a model
- Inside the model
- Your first real agent
- Hardening and testing the loop
- Streaming the loop
- Designing tools
- Context and memory
- Concurrency
- MCP
- Providers and SDKs
- Reliability and observability
- Testing and evals
- Safety and human approval
- Durable, deployed agents
- Frameworks in context
- Capstone: the crash-triage agent
Editorial Reviews
Editorial Reviews
About the Author
Dayna Blackwell is the founder of Blackwell Systems, where she builds infrastructure for AI agents in Go and measures what she builds. Her open-source tools are used by more than 120 repositories across more than 60 organizations, with over a million downloads. They include bide, a Go framework for durable agents; GCF, a data format that cuts the tokens LLMs spend on structured data, used by nearly 30 projects outside Blackwell Systems, including Googleʼs Chrome DevTools MCP; and agent-lsp, whose agent skills NVIDIA Labs includes in its Skill2Env collection. She is a top-10 contributor to mcp-go, with fixes merged into the official MCP SDKs for Go, Python, and PHP, and more than 50 pull requests merged in all, into projects from Google, Grafana, and HashiCorp. She has written 11 papers, including a theory of when replicated systems converge, machine-checked in Coq. Earlier, she spent five years as the technical owner of Best Westernʼs loyalty platform, serving tens of millions of members at thousands of hotels in over 100 countries. She is also the author of You Donʼt Know JSON.
Wow! eBook


