First Principles / Part VI · Best practices & tools / Chapter 34
First Principles · Best practices & tools · 34
The AI toolchain looks chaotic — hundreds of products, all changing monthly. But it resolves into a stack of layers, each a category with a durable purpose even as the tools inside it churn. And every layer maps to a chapter you've just read.
01The answer, then the intuition
The tool landscape feels overwhelming because people present it as a list of products. It isn't — it's a stack. From the model at the bottom to the guardrails at the top, each layer does one job, and whatever product is popular this quarter, the job stays the same. Learn the layers and the churn stops mattering: when a tool changes, you already know what slot it fills.
Better still, this stack is the book. Every layer is a chapter you've read — which means you already understand the whole toolchain from first principles. Click through it:
Each layer is a category; the tools are examples, not endorsements. Each maps to a chapter.
02Mechanics
The practical advice falls straight out of this shape: pick each layer by need, keep the interfaces clean so you can swap a tool without a rewrite, and don't marry a framework — the categories are stable, the products are not. Understanding beats tooling, because understanding is what tells you which tool you actually need.
04The math
expand ▾An AI application is literally a composition of the layers — the output of one feeds the next, top wrapping bottom:
Read inside-out: route the request to a model, retrieve grounding context, generate conditioned on both, then guard the output. Because it's a composition, each layer is independently swappable — change the retriever without touching the router — which is exactly why clean interfaces matter more than any single tool. The math of the stack is the math of function composition: understand each function, and you understand the whole system, regardless of which library implements each one.
05The code
expand ▾Every chapter, composed into a single AI app. The tools are stubs; the shape is the point.
app.py
def route(task): # ch31 — cheapest model that clears the bar
return "mid" if task["easy"] else "frontier"
def retrieve(query): # ch21 / ch25 — grounding via vector search
return ["Refunds within 30 days."]
def generate(model, ctx, q): # ch20 — prompt, conditioned on context
return f"[{model}] {q} -> grounded in {ctx[0]}"
def guard(text): # ch33 — safety filter on the output
return text if "leak" not in text else "[blocked]"
def app(task): # the composition (ch34)
model = route(task)
ctx = retrieve(task["q"])
draft = generate(model, ctx, task["q"])
return guard(draft)
print(app({"q": "What's the refund window?", "easy": True}))
print(app({"q": "Draft a legal brief.", "easy": False}))
# [mid] What's the refund window? -> grounded in Refunds within 30 days.
# [frontier] Draft a legal brief. -> grounded in Refunds within 30 days.
06The economics
The stack → money
The tool market churns violently — frameworks rise and fall in quarters, and betting your architecture on any one is a real liability. But the layers are stable, because they map to physics and economics that don't change: you will always need to run a model, ground it, orchestrate it, measure it, and guard it. The teams that stay fast are the ones that understand the layers and treat the tools as replaceable.
That's the meta-lesson of this whole book, and the reason it was written from first principles rather than as a tutorial for today's products. Tutorials expire; understanding compounds. Every layer of this stack is a chapter, and every chapter connected the mechanics to the money — because in the end, choosing tools is an economic decision, and you can only make it well if you understand what each layer actually costs and buys.
For the Circuit, that's the point of the exercise. An honest read on AI's economics requires understanding AI's mechanics — you cannot judge whether the tokens will pay for the clusters without knowing what a token is, what it costs, and what it can do. This book was the foundation. The rest of the site is what we build on it.
First Principles — complete
You started with what a token is. You end knowing how a frontier model is built, trained, aligned, run across a warehouse of chips, deployed with prompts and retrieval and agents, measured, secured, priced — and why any of it might or might not pay for itself. From the smallest unit to the $500 billion question, from first principles, with the code run and the math checked.
The unfair advantage was always the bridge — connecting every mechanic to its economics. That's what makes this more than a textbook, and it's what the rest of Divergent Compute is built to do: turn understanding into an honest read on where this is all going. Back to the curriculum →
07Going deeper
expand ▾
LangChain / LangGraph · orchestration & agent frameworks.
vLLM · the open serving engine behind much of the batching layer.
Model Context Protocol (MCP) · an open standard for the tool/agent layer.
Awesome-LLMOps · a maintained map of the whole tooling landscape.
Cite this chapter: Divergent Compute, "The tool landscape", First Principles, 2026. divergentcompute.com/first-principles-tool-landscape · v1.0 · CC-BY. First Principles is complete: 34 chapters, six parts, open and forkable.