Framework Landscape
What frameworks sell, what they cost you, and how to choose one.
Chapters 18 to 20 built an agent from parts: a loop, a harness, and a policy for its context. Frameworks sell those parts pre-assembled. This chapter is a map of what is on sale, what each kind of framework wraps, and how to decide whether to buy.
Brand names in this area change quickly, and the ones here were checked in November 2026. The chapter is organized by category for that reason: the categories correspond to patterns you already know, and they will outlast the brands.
21.1Categories, not brands
The names change every year and the layers do not.
| Category | What it wraps | Examples in late 2026 | The pattern underneath |
|---|---|---|---|
| Provider SDK | One vendor’s API, with helpers for tools and streaming | The OpenAI, Anthropic and Google SDKs | Chapter 11 |
| Model toolkit | One interface over many providers | Vercel AI SDK, Pydantic AI, LangChain’s core | Chapter 11, made portable |
| Orchestration library | Chains of model calls, retrieval pipelines, many integrations | LangChain, LlamaIndex, Haystack | Sections 13.6 and 15.1 |
| Agent graph | An explicit state machine around the loop, with saved state | LangGraph, and the workflow layers of Mastra and Microsoft Agent Framework | Chapters 18 and 19, drawn as a graph |
| Agent harness | A complete loop with tools, memory and context management built in | Claude Agent SDK, OpenAI Agents SDK, Google ADK | Chapters 19 and 20, pre-built |
| Multi-agent framework | Role-based teams of agents passing messages | CrewAI; Microsoft Agent Framework, the successor to AutoGen | Section 19.9 |
| Gateway | One endpoint in front of many providers | LiteLLM, OpenRouter, cloud gateways | Section 11.10 |
| Evaluation and tracing | Test runners and trace stores | Covered in their own chapters | Chapters 23 and 24 |
The right-hand column is the point of the table. Every category is a packaging of something from an earlier chapter. If you know the pattern, you can pick up any brand in a day, and you can also tell when the right amount of framework is none.
The churn is real. In the past two years one widely used multi-agent framework went into maintenance and was folded into a successor, and two of the best-known libraries only recently settled into stable version lines. A list of brands memorized today is out of date within the year.
Common take“I know LangChain, LlamaIndex and CrewAI.”
Sharper take“I know the categories and what each one wraps. That lets me learn any brand quickly, and it lets me say when ten lines of my own code are the better choice.”
21.2The abstraction tax
What a framework gives you, and the invoice.
| A framework gives you | And charges you |
|---|---|
| Breadth of integration: adapters for a hundred models, vector stores and document loaders from the first day | Indirection: your prompt is assembled by code you did not write. When quality drifts, you dig through layers to find what the model was sent |
| Scaffolding: retries, streaming and tool loops already wired | Hidden defaults: a chunk size, a number of retrieved passages, a prompt template you never chose, each now carrying weight (section 15.3) |
| Speed to a prototype: an idea to a demonstration in an afternoon | Version churn: an upgrade can change behavior with no change to your code |
| Community: documentation, examples, people who already know it | Mismatch: when your flow needs a step the framework did not foresee, you fight the framework where ten lines would have done |
One rule removes most of the right-hand column: always be able to print the compiled prompt. Whatever a framework assembles, log the final list of messages for each request (Chapter 24). It is the versioning discipline of section 13.8 applied to code you do not own.
Common take“We upgraded the library. It was only a minor version.”
Sharper take“A framework upgrade can change the prompt, so I treat it as a prompt release: pinned versions, a diff of the compiled prompt, and the test set as the gate.”
21.3Orchestration libraries
Pipelines and retrieval, pre-assembled.
LangChain is the generalist. Its central idea is the pipeline of section 13.6, written as a chain of components: a prompt template, then a model, then an output parser, with streaming and retries available on the whole. Its strengths are the range of adapters, which makes swapping a provider or a vector store a one-line change, and speed to a first version. Its cost is the full invoice of section 21.2: deep indirection, and prompts assembled a long way from where you are looking.
LlamaIndex is the retrieval specialist. Its core objects are the two pipelines of section 15.1 by name: ingestion, index, retriever, query engine. The chunking strategies of Chapter 15 and the parts catalog of Chapter 16, rerankers, routers and query decomposition, come as components. If the product is retrieval at its center, these defaults start closer to right.
The usual mature posture with either one has two stages. Prototype on the framework to find out whether the feature is worth building. Then either thin it out, keeping the loaders and integrations while owning your prompts and retrieval logic, or keep it and enforce the disciplines of section 21.2.
Common take“Should we use LangChain or LlamaIndex?”
Sharper take“Which stage of my pipeline needs whose defaults, and which defaults will I refuse to inherit without looking? I take the integrations and keep my prompts and retrieval settings where I can see them.”
21.4Agent graphs
Control flow you can read, with state that survives.
The free loop of section 18.1 hides its control flow inside the model’s choices. A graph framework makes the control flow an object you can read and review. Nodes are functions: a model call, a tool, a guard. Edges are transitions, some of them conditional. A typed state object is passed along and saved.
A sketch in the style of LangGraph, the best-known framework of this kind. Treat it as an illustration and check the current documentation for exact names.
class State(TypedDict):
messages: list
plan: str
step_count: int
graph = StateGraph(State)
graph.add_node("plan", make_plan) # the planner of section 18.4, as a node
graph.add_node("act", run_tools) # the body of the loop
graph.add_node("guard", output_guard) # section 19.4, as a node and not a hope
graph.add_conditional_edges("act", # the budget is an edge you can read
lambda s: "act" if more_steps(s) and s["step_count"] < 10 else "guard")
app = graph.compile(checkpointer=database) # state saved after every stepThe shape buys four things that a bare loop lacks.
- Budgets and guards become structure. A step limit is a condition on an edge, visible in review, where before it was a convention inside a while-loop.
- Saved state gives durable execution. A run that crashes at step six resumes at step six (section 19.8).
- Approval is a place the graph waits. A person responds, and the run continues from saved state.
- Runs can be replayed. Any saved step can be loaded and re-run with changes, which is the most useful debugging tool there is for behavior that varies from run to run.
The costs are a real learning curve, boilerplate for simple flows, and a state store that you now operate. A three-step pipeline does not need a state machine. Graphs earn their place exactly where section 18.10 said agents do: long, interruptible, approval-gated work that must be able to resume. In a sense this category is the workflow-first doctrine shipped as software, with the deterministic skeleton primary and the model’s freedom confined to labeled nodes.
Common take“We use a graph framework for all our AI features.”
Sharper take“I use a graph where a run has to wait for a person or survive a restart, because saved state and readable control flow are what it sells. For a five-step tool loop, twenty lines and a harness are less to own.”
21.5Multi-agent frameworks
A sound pattern in an expensive costume.
These frameworks let you declare a team: a researcher, a writer, a critic, each an agent with a role, passing work along in sequence or under a manager. Section 19.9 set out what that can honestly buy: clean context windows, independent checking, parallel work. The question is what the packaging adds.
Inside one process with one owner, a message from one “agent” to another is this:
crew.hand_off("Researcher" -> "Writer", content=prose_summary)
is the same as
writer_step(researcher_output) a function call, but with prose as the wire format:
no type checking
lossy serialization: nuance dropped
tokens billed per hop, as transcripts are re-read
nondeterministic parsing at the receiving endThat is the precise meaning of the phrase function calls in costume. The pattern is sound: decompose, specialize, verify. The costume, prose passed between colleagues who share a process, adds cost and loss without adding any isolation you could not get from a typed pipeline stage with its own context window.
The failure these frameworks make easy is architecture by org chart. When agents are cheap to create, teams of them get built, and the traces show agents thanking each other, redoing each other’s work and summarizing summaries.
Common take“Each role in the workflow is its own agent, so they can collaborate.”
Sharper take“A role is usually a system prompt on a pipeline stage. I pass typed data between stages, and I make something a separate agent only when it needs its own context window or has to check the work independently.”
21.6Vendor SDKs and a thin harness
The plain option, which is often the right one.
The model providers’ own SDKs now come with agent scaffolding: a tool loop, hosted tools such as web search and code execution, and MCP support. Their agent SDKs go further and ship a whole harness. One of them is, in effect, the provider’s own coding agent packaged as a library, with context management and sub-agents included. For a team committed to one provider, these cover a good part of the ladder in section 19.10 with little abstraction in the way.
| Vendor SDK plus your own thin harness | Cross-vendor framework | |
|---|---|---|
| Depth of abstraction | Shallow: you see every message | Deep: the invoice of section 21.2 |
| Lock-in | Real and bounded: the surface is the mechanics of Chapter 11, which you understand and can port | Portable in name; lock-in to the framework replaces lock-in to the vendor |
| New model features | Available on the day they ship | Available when the framework adds them, sometimes in reduced form |
| State kept on the vendor’s servers | Convenient, with the data questions of section 11.9 | State is on your side: your problem, and your asset |
| Fits | One provider, standard patterns, a team that wants to see what is sent | Several providers or stores, or a need for one of the framework’s larger features |
The thin-harness posture is the combination: the vendor’s SDK for the calls, and a few hundred lines of your own for validation, budgets, guards and logging, written once and understood completely. It is unglamorous, and for many products it is the design with the fewest surprises.
Common take“Using only the vendor’s SDK isn’t a real architecture.”
Sharper take“The vendor’s SDK plus a small harness I wrote is often the most maintainable choice. I can read every message, new features arrive immediately, and the only abstraction is one I understand.”
21.7Gateways, TypeScript and compiled prompts
Gateways, the TypeScript stack and compiled prompts.
Three more kinds of tool sit beside the main categories.
Gateways and routers. A gateway is a service between your code and several providers, presenting one API (section 11.10). It is the natural home for fallbacks, budgets per team, rate limits and uniform logging, and it lets routing rules change without a deployment. Its costs are a network hop, one more thing that can fail, and features reduced to what all providers share. A gateway is infrastructure and combines with any framework above it.
The TypeScript stack. Much product code is TypeScript, and that ecosystem has its own tools. The Vercel AI SDK is a model toolkit with streaming to user interfaces built in, and Mastra adds workflows, memory and evaluation on top. The categories are the same as in Python. The practical point is that a team should not move languages to follow a framework.
Compiled prompts. DSPy takes a different approach from all of the above. You declare what goes into each step and what should come out, supply examples and a metric, and an optimizer searches for the instructions and examples that score best (section 13.9). The prompt becomes an output of a build step, regenerated when the model changes. It pays where a pipeline has a clear metric and enough labeled data, and it depends entirely on the quality of that metric.
Common take“We need to pick one framework for the whole stack.”
Sharper take“These are layers, and they combine. I might run a gateway for routing and budgets, the vendor’s SDK for calls, and a graph only for the one flow that needs saved state.”
21.8Case study: a personal agent
A personal agent with every permission.
In January 2026 an open-source project called OpenClaw became one of the fastest-growing repositories on record. It is a personal assistant that you run yourself: always on, reachable through your messaging apps, with access to your files, your email, your browser and a shell. It is the loop of Chapter 18 with as many tools as possible and as much untrusted input as possible. What followed is the clearest public lesson so far in what Chapter 19 is for.
| What was reported | The mechanism | The harness layer that addresses it |
|---|---|---|
| An email containing hidden instructions led an agent to hand over a private key when asked to check the inbox | Indirect prompt injection: the agent reads untrusted text and has the tools to act on it | Action gates on anything irreversible; outbound network limits (sections 19.4 and 19.6) |
| An audit of the community skill registry found 341 malicious skills among 2,857 | Skills ran with the agent’s full privileges, and anyone could publish one | Allow-listed, reviewed extensions; sandboxed execution (sections 18.7 and 19.6) |
| Thousands of instances were found reachable from the internet, some leaking credentials | A tool built for one trusted user, deployed as if it were a hardened service | Least-privilege credentials; no secrets in reach of the loop (section 19.6) |
| Researchers described instructions planted in memory on one day taking effect on another | Whatever is stored is read back later as trusted context | Treat the write path to memory as a trust boundary (sections 18.5 and 20.5) |
A useful summary of the underlying problem is the security researcher Simon Willison’s “lethal trifecta”: an agent that has access to private data, is exposed to untrusted content, and is able to communicate externally can be made to leak the first through the second by way of the third. A personal agent with every permission has all three by design.
The lesson is not that the project was careless; its documentation was open about the risks. It is that capability and exposure arrive together, and that no amount of prompting separates them. The controls that work are the ones enforced outside the model. Chapter 26 takes this up in full.
Common take“It’s my own assistant on my own machine, so there’s no security problem.”
Sharper take“It reads email and web pages that other people wrote, and it can run commands and send data. Private data, untrusted input and a way out, all in one loop: the attacker doesn’t need my machine, only something my agent will read.”
21.9Choosing
Decide by what you need to own.
| Situation | Reasonable choice | Why |
|---|---|---|
| A prototype to test whether a feature is worth building | An orchestration library or a vendor agent SDK | Speed matters most, and little will survive anyway |
| One provider, a standard chat or tool-calling product | The vendor’s SDK and a thin harness of your own | Fewest layers; you see every message |
| A retrieval-centered product | A retrieval library for ingestion and integrations, with your own prompts and settings | Take the plumbing, own what determines quality |
| Runs that wait for approval or must survive restarts | An agent-graph framework, or a workflow engine | Saved state and readable control flow are what you are buying |
| An agent that works on files and a shell | A vendor’s agent harness | Context management and tool design are already done well |
| Several providers, shared budgets and fallbacks | A gateway, under whatever else you use | Routing and limits belong in infrastructure |
| A pipeline with a clear metric and labeled data | Compiled prompts, for the stages that have the metric | The optimizer needs the metric; with one, it usually beats hand-tuning |
Four questions sit behind the table, and they apply to any brand that appears next year. Can I print exactly what is sent to the model? Can I pin the version and test an upgrade before it ships? If the framework disappeared, how much would I have to rewrite, and do I understand the pattern well enough to do it? And what does it do that ten lines of my own would not?
Common take“Which framework is the best one?”
Sharper take“It depends on what I need to own. I ask whether I can see the compiled prompt, pin the version, and replace the framework if I had to. The answers decide it, and sometimes the answer is no framework.”
Key takeaways
- Framework categories map onto patterns from earlier chapters. Learn the categories; the brands change every year.
- A framework trades integration and speed for indirection, hidden defaults and version churn.
- Always be able to print the compiled prompt, and treat a framework upgrade as a prompt release.
- Orchestration libraries are pipelines and retrieval pre-assembled. Take the integrations, and own the prompts and settings that determine quality.
- Agent graphs make control flow readable and state durable. They pay for runs that must wait or resume.
- Inside one application, agents passing prose are function calls in costume. A role is usually a system prompt on a stage.
- A vendor SDK with a thin harness of your own is often the design with the fewest surprises.
- Gateways, model toolkits and prompt compilers are layers that combine with the rest.
- A personal agent with private data, untrusted input and a way to send data out has every ingredient an attacker needs. In one audit, 12% of a public skill registry was malicious.
- Choose by what you need to own: the prompt, the version, and the ability to leave.
Check your understanding
-
After a routine update of dependencies, your retrieval assistant’s answers get noticeably worse. Your own code and prompts have not changed, and the model version is pinned. Where do you look, and what process change prevents a repeat?
Answer outline
Look at what is actually sent to the model. Log the compiled prompt for the same request under the old and new versions and compare them: a default prompt template, the default number of retrieved passages, a chunking default or a parser may have changed inside the framework. Also compare retrieved passages for the same queries. To prevent a repeat: pin framework versions, log the compiled prompt in production, and run the labeled test set as a gate on every dependency upgrade, exactly as for a prompt change.
-
A team has built a five-agent crew, with a planner, a researcher, an analyst, a writer and an editor, to produce market summaries. Quality is comparable to a single careful prompt, at about eight times the cost and four times the latency. How would you restructure it, and what would you keep?
Answer outline
Treat the roles as stages of a pipeline, not agents. Retrieval and analysis become steps that pass structured data, with schemas, in place of prose handoffs; writing becomes one call with the structured findings as input. Keep a separate context only where it buys something: an independent checker that sees the sources and the draft, or a sub-agent for research if the search would otherwise flood the main context. Give each stage its own tests. Measure quality, cost and latency against the single-prompt baseline, and keep any stage only if it beats that baseline.
-
Your company wants to give employees a self-hosted personal assistant with access to email, the calendar, internal documents and a browser. Using section 21.8, state the main risk in one sentence and name four controls you would require before a pilot.
Answer outline
The assistant combines private data, untrusted content such as incoming email and web pages, and the means to send data out, so anyone who can get text in front of it may be able to steer it. Controls: actions that send, share, delete or pay require confirmation that shows the consequence; outbound requests go only to allow-listed destinations; extensions and tool servers are allow-listed, reviewed and sandboxed, with nothing installed from a public registry unvetted; credentials are scoped per tool with least privilege and kept out of the agent’s reach; and everything it reads from outside is treated as data, with what it writes to memory reviewed. Then run adversarial tests before any pilot.
Further reading
- The documentation of whichever framework you are evaluating: read the pages on what is sent to the model and on saved state before the quick-start.
- Micheal Lanham, AI Agents in Action, 2nd edition (Manning, 2026): the chapters on a vendor agent SDK and on MCP.
- Simon Willison, “The lethal trifecta for AI agents”: the short essay behind section 21.8.
- Anthropic, “Building effective agents”: its advice on frameworks is brief and matches this chapter: start with the provider’s API, and understand what any framework does underneath.