Part 9 · 6 chapters

Advanced and Cutting-Edge Topics

The frontier moves fast. This part covers the latest approaches — agentic and graph-based RAG, evaluation and observability, safety and security, cost optimization with small models, and production deployment.

Chapter 43Advanced and Cutting-Edge Topics

Agentic RAG and GraphRAG

Part IX takes you to the cutting edge — the techniques and concerns that separate a hobby agent from a production-grade one. We begin where retrieval left off. The basic RAG of Chapter 36 was a fixed pipeline: embed the question, retrieve, generate. It works, but it is rigid. This chapter shows two ways retrieval grows up: **agentic RAG**, where the agent decides for itself when and how to retrieve, and **GraphRAG**, which retrieves over a web of connected facts rather than isolated chunks. Both make retrieval smarter, and both build directly on what you already know.

Chapter 44Advanced and Cutting-Edge Topics

Evaluating and Observing Agents

Chapter 25 taught you to evaluate models; agents are harder still. A model produces one output you can judge, but an agent takes many steps — reasoning, calling tools, observing results — and any of them can go wrong. To know whether an agent works, you must be able to *see* what it did and *judge* the whole path it took, not just its final answer. This chapter covers observability (seeing the agent's steps) and evaluation (judging its behavior), the twin disciplines that turn a black box into something you can trust and improve. For agents that take real actions, this is not optional.

Chapter 45Advanced and Cutting-Edge Topics

Guardrails, Safety, and Security

This chapter has been foreshadowed since Chapter 1, and now it arrives. An agent that takes actions in the world can cause real harm in a way a chatbot never could — and the more capable your agents become, the more this matters. We confront agent safety and security directly: the central threat of prompt injection, the danger of tool misuse, and the layered guardrails that keep agents in check. None of this is about fear; it is about building responsibly. An agent you cannot keep safe is an agent you should not deploy, and this chapter is how you keep it safe.

Chapter 46Advanced and Cutting-Edge Topics

Small Models, Local Agents, and Cost Optimization

There is a powerful instinct, when building agents, to reach for the biggest, most capable model for everything. It is usually a mistake — an expensive one. Many tasks do not need a frontier model, and using one anyway wastes money and time. This chapter is about doing more with less, deliberately: when a small model is the right choice, how local agents fit in, the routing pattern that combines small and large models, and the concrete levers for controlling cost. Right-sizing your models to your tasks is one of the most practical skills in production agent building.

Chapter 47Advanced and Cutting-Edge Topics

Deploying Agents to Production

A working agent in a notebook is a wonderful thing — and it is not a product. Production means turning that prototype into a service others can rely on: reliable when things go wrong, monitored so you know how it behaves, secure against attack, affordable at scale, and maintainable as it evolves. This chapter covers the gap between "it works on my machine" and "it works for real users," pulling together threads from across the book into a practical guide for shipping agents responsibly. It is the difference between a demo and dependability.

Chapter 48Advanced and Cutting-Edge Topics

The Frontier: Latest Developments and What Comes Next

We close Part IX by looking outward — at where the field is heading and, far more usefully, at how to keep up as it gets there. A chapter titled "the latest developments" risks being out of date by the time you read it, so this one is built differently. Rather than a snapshot of today's headlines, it offers durable directions, the problems that will stay hard for a while, the fundamentals that will not change, and a practical habit for staying current. The half-life of a specific tool is short; the half-life of a way of thinking is long, and that is what we aim for here.

← Part 8Part 10