Part II — Empowering Graphs with LLMs
In Part I the nodes were hard-coded: given the same input they did the same thing, every time. Now we drop a real language model into them — served locally, so it still costs nothing — and the graph stops being a deterministic machine and starts making decisions of its own. The structure you already built barely changes; what changes is that a node’s output is now a judgment rather than a lookup.
That judgment is the most powerful and the least predictable part of the whole system. You will take structured output and watch it hand back a well-shaped but wrong answer; add tool-calling and see the model skip the tool it should have used; give the bot memory across turns and a supervisor that routes between sub-agents; and stream tokens out as they are produced. The thread running through all of it: the graph is where the guardrails go, precisely because the model will not always stay inside them.
The part closes by acting on that. Middleware hangs those guardrails on the seams of the prebuilt agent loop without your reopening the graph. Then a test suite pins everything the model isn’t — state shape, reducers, edges, tool dispatch. That suite scripts the model out, so a red build there means someone changed the code, not that the model had an off day. That line — between what you wrote and what the model decided — is what Part III builds on.
Part II reaches past Part I’s two packages, one chapter at a time and with a pinned install line where each arrives: langchain-openai to talk to a model (12 A Real LLM), langchain for the prebuilt agent (13 Tool-Calling), ddgs for a real web search (16 Multi-Agent Supervisor’s web worker; 13 Tool-Calling’s Gold reaches for it too), and pytest (20 Testing) — the book’s only dev-time dependency, and the one thing here that nothing you ship will import.

