Back to the map

Module 15 · Protocols and frameworks · Lesson 5 of 5

Agent frameworks compared

What a framework gives (the loop, state, tool wiring, streaming, persistence, tracing) and costs (hidden prompts, harder debugging, churn), the four shapes, and the rule: start with the model API, add a framework for a concrete need.

CoreShould-knowMid 12 minPro Updated Nov 2026

Why it matters

The agent loop is about fifty lines: send messages and tool definitions, read the stop reason, run the tool, append the result, repeat. A framework wraps those lines in a few hundred thousand more. That can buy durability a team would otherwise write badly, or hide the prompt and turn a wrong answer into a two-day debugging session. Interviewers ask which framework you would use because the honest answer shows whether you know what the loop is, what a framework adds, and what it takes away.

The idea

What a framework gives you

The loop, so you do not write it. State that survives a step. Tool wiring from a function signature to a schema and back. Streaming of tokens and tool events to an interface. Persistence, so a run can pause and resume. Tracing hooks, so each step lands in an observability tool.

What it costs

Abstraction over the prompt: the framework assembles the system prompt, the tool descriptions and the history, and what the model sees is no longer what you wrote. Debugging gets harder for the same reason: a wrong answer could come from your code, the prompt assembly, a retry policy or state handling. Churn: a major version can rename the core abstractions. Anthropic's advice, which this track follows, is to start with the model API directly and add abstraction when a concrete need appears.

Four shapes

Graph-based. You declare nodes (a step that calls the model or a tool) and edges (which step follows which). The graph is explicit, so a run can be checkpointed at any node and resumed or replayed. LangGraph is the reference example, with LangChain beneath it for components. Good for workflows with known structure and anything that must survive a crash or a week-long pause.

Loop-based SDKs from model providers. A thin layer over the provider's API: an agent is a model, instructions and tools; a run is the loop; handoffs pass control between agents. The OpenAI Agents SDK, the Claude Agent SDK and Google's ADK sit here. Little hidden, easiest to debug, and tied to one provider unless the SDK abstracts it.

Role-based multi-agent. A crew of named roles, each with a goal, a persona and tools, handing work along a process. CrewAI is the well-known one; Microsoft's AutoGen and Semantic Kernel offer multi-agent orchestration in a similar spirit. Fast to prototype; the roles are prompts you did not write, and control flow lives in the conversation.

Minimal code-agent libraries. A small core where the model writes code that calls tools. Hugging Face's smolagents is the example. Tiny, transparent, strong for data tasks, and it needs the sandbox the Code execution and sandboxes lesson describes.

graphplanactcheckprovider SDKmodeltoolslooprolesleadsearchwriteminimalmodelrun codedurable, explicitthin, close to APInamed rolestiny, sandboxed
Four shapes: an explicit graph you can checkpoint, a thin loop over the provider API, a crew of named roles passing work, and a small core where the model writes code.

The choosing rule

Start with the model API and your own loop. Add a framework when one of three needs appears: durability, because runs must pause for a human or survive a restart; multi-agent structure, because several loops must hand work to each other in a defined way; or team conventions, because a team needs one way to write agents. If none applies, the framework is cost without benefit.

Lock-in and exit cost

The exit cost is the number of places the framework's abstractions touch your code: prompts in its template language, state in its checkpoint format, tools registered through its decorators, traces in its schema. Keep the exit cheap: own your prompts as plain strings, define tools as plain functions with the schema beside them, and keep evaluation outside the framework. Tools behind an MCP server and peers behind A2A outlive whichever framework drives the loop this year.

Evaluating one in a day

Morning: build the smallest real task from your product with the bare API and keep the transcript. Midday: build the same task in the framework. Afternoon: print what the model receives on each step and compare; break a tool and see how the error surfaces; kill the process mid-run and see what resumes; check the trace. If you cannot see the prompt or cannot resume, you have your answer.

 Graph-basedProvider SDKRole-basedMinimal code agent
ControlExplicit nodes and edges; you own the flowYou own the loop's inputs; the SDK owns the loopThe conversation decides; roles are promptsModel writes the control flow as code
DurabilityCheckpoint at any node; resume, replaySession state; durability is yours to addLittle; a run is a conversationLittle; a run is a script
Learning curveHighest: graph, state schema, checkpointersLowest if you know the APILow to start; hard to steer laterLow; small surface
Lock-inState format and graph DSLOne provider, unless abstractedRole and process abstractionsMinimal; near plain code
Agent frameworks compared · Backplane