Agentic AI Foundations takes you from a single call to a language model to a working, tested AI agent that you understand line by line. No framework hides the moving parts: you write the model client, the tool-calling cycle and the agent loop yourself, in plain Python, and test each piece before you build on it.
Every chapter works on the same realistic company, Kestrel Outfitters, a home and outdoor goods retailer with support tickets, orders, shipments, stock and policies served by a local mock API. The examples answer the kind of questions its staff really ask, so you see where an agent helps, where a fixed workflow is the better choice, and what each design decision costs.
What's inside
- Part I: What agents are and how models work. The difference between a workflow and an agent, the autonomy spectrum, and just enough about tokens, context windows, sampling and reasoning models to make good decisions. Then the Messages API, system prompts, streaming, and prompts written for agents.
- Part II: Tools and the agent loop. Structured outputs with JSON Schema and validation, tool calling from first principles, the agent loop with explicit stop rules and run budgets, and how to design tools a model can use well.
- Part III: Context, models and testing. What goes into the context window and why, short-term memory with summarisation and compaction, how to choose a model on capability, latency and cost, when a framework helps, and how to test an agent with golden tasks, traces and simple evals.
- Part IV: Capstone. Design, build and harden a research assistant for Kestrel's CTO: it searches, reads files and cites its sources, stays within a cost limit, and ships with an eval suite.
How the code works
Each chapter has its own folder in the companion repository, with runnable code, tests and the exact output shown in the text. Everything runs on your laptop with Python 3.12 and uv: a fake model and the local Kestrel mock API mean you don't need an API key or an account to follow along. Fake-model output is labelled as such in the text. When you want to, you can point the same code at a real model with your own key.
Who it's for
Backend, full-stack and data developers who write Python and have called an HTTP API, and want to build AI agents properly, from the ground up. No machine learning background is needed.
This is book 1 of the free Agentic AI series. Later books cover context, memory and retrieval; tools and protocols (MCP, A2A and Agent Skills); design patterns; multi-agent systems; and running agents in production.
Kestrel Outfitters is a fictional company; any resemblance to real businesses or products is coincidental.

