Agentic AI series · Book 1 • Free to read • Python
Agentic AI Foundations
From LLM Calls to Your First Agent
- 16Chapters
- 600+ testsTested code examples
- 3.12Python
- NoneAPI key needed
- Python developers who have called an HTTP API and want to build AI agents from the ground up. No machine learning background needed.
Updated Nov 28, 2026 · v1.0EnglishFree · HTML
What makes a program agentic, and when a plain workflow is the better choice. Just enough about how language models work, how to call them through the Messages API, and how to write prompts that agents can follow.
- 1
Defines an agent as a program where a model chooses tools in a loop and decides when to stop, inside a run budget enforced by code, and gives one runtime test to tell it from a workflow. Places five Kestrel requests on the autonomy spectrum by cost, risk and predictability, then sets up the uv project, the Kestrel mock API and a deterministic order-status workflow with tests.
- Agentic AI
- Python
- 2
Treat a model call like any backend dependency. Count the tokens in a Kestrel handbook page and price them from configured rates, then price a five-step run. Check requests against the context window that input and output share. See how temperature reshapes token choices on a toy sampler and why the same prompt gives different answers. See what reasoning models cost in tokens and latency. The tests run offline on fixture responses.
- LLMs
- 3
Call a language model from Python through a small provider-neutral ModelClient. Configure it from environment settings, send a system prompt and messages, read content, stop reason and token usage, and price each call with Decimal. Stream a reply to the terminal, bound calls with timeouts, output caps and SDK retries, turn API errors into one clear message, and test everything offline with a scripted fake model.
- LLMs
- Python
- 4
Structure a system prompt into role, task, constraints, data and output format, plus an explicit don't-know rule, with each ticket delimited and escaped in the user message. Learn when few-shot examples help and when the model copies them, then keep prompts as versioned files and compare two versions on the same five Kestrel support tickets.
- Context Engineering
- Agentic AI

Bishal SahaLet's build together
Have a system to design, or an AI feature to get right?
Tell me about the problem. You'll get a clear, honest view of the best way forward.
- Reply within 24 hoursOn business days, with my honest view and a next step.
- Accepting select engagementsArchitecture, AI features and full builds.
- Remote, worldwideWorking with startups, SMEs and enterprises.
