Topic: agentic-frameworks

The building blocks you assemble an agent from when you do not take a finished harness (orchestration libraries, gateways in front of the model providers, tracing and evaluation, hosted runtimes), compared on one map, with three labs that run the same agent several ways. Data as of October 2026. Reading: 28 min, plus 3 in closed details.

This root is a map: it compares the building blocks and defines what the comparison needs; each block is taught on its child page (section 11). Measured numbers come from runs recorded on 5 and 6 October 2026 with the Claude Code CLI 2.1.289 on a Claude subscription (no API key), kept redacted in this page's source; dollar figures are the API-price equivalent the CLI reports, not money paid. MEASURED marks those numbers, SOURCE marks published ones with their date.

The idea in one screen

An agent framework is a library that writes part of the agent loop for you; every one sits somewhere on one line, how much of the loop you own, and is worth adopting only for a capability you would otherwise build by hand and get wrong: saved state you can resume, a human pause, typed results, traces.

The sibling topic, Topic: agentic-harnesses, takes a finished agent apart: the agent loop (call the model, run the tool it asks for, show it the result, repeat until it stops), tools, context, permissions. This topic is the parts you assemble when you build your own. Fig. 1 adds them one at a time around one loop; each step names the page that owns the block.

  1. The loop every framework runs. Your app hands the agent loop a job. The loop sends the conversation and the tool list to a model provider; the model answers or asks for a tool; the loop runs it, appends the result and calls again until the model stops. Written by hand it is about 15 lines (the Same agent tab's version 1). How the loop works: Building a harness.
  2. Orchestration: who picks the next step, and the run's state. A library takes over the loop. The schools differ in what they make you describe: a graph runtime (LangGraph, LangChain and LangGraph), a typed loop (Pydantic AI, OpenAI Agents SDK, smolagents, Google ADK, Typed agent libraries), a harness as a library (the Claude Agent SDK), roles and crews (CrewAI, Microsoft Agent Framework, owned by this page). Workflows or agents, the schools and typed results: sections 1, 2 and 4.
  3. State: checkpoints within a run, memory across runs. After every step the run's whole state is saved under a thread id, so a crash or a human pause resumes instead of starting again (section 3, Fig. 3). Facts kept across sessions (facts, temporal graphs, paged context) are another store, owned by Context engineering, section 8.
  4. Several loops cooperating. A lead hands pieces of the job to workers, each with its own prompt, tools and context, and reads back their reports: orchestrator-workers, handoffs, blackboard, debate (section 5, Multi-agent patterns).
  5. A gateway: one endpoint over many providers. Every model call goes to one proxy that holds the keys, budgets, retries, fallbacks and routing, and forwards it to Anthropic, OpenAI, Google or a model you serve (section 6, Gateways and routing).
  6. Observability: a trace of every step. Each model call and tool call becomes a span with its tokens and cost; one run is a tree of spans, and evals score them (section 7, LLM observability).
  7. Or buy the whole loop. At the far end of the axis a hosted runtime runs the loop, the tools' sandbox and the session on the vendor's servers; your app sends a task and receives events (section 9).

Orchestration decides the next step; everything else wraps each model call. Drag the figure to turn it. The labs put the whole stack around one running agent.

The running example. Both agent topics use one job: a tiny Python library, textstats, with two planted bugs (the tokenizer splits don't into don and t; top_words does not break ties alphabetically) and a test file that catches both. The prompt, word for word: "The tests in this repository fail. Find out why and fix the code so they pass. Do not edit the tests." Three tabs run it for real: Same agent, six ways (one agent in a plain loop and five frameworks), the Orchestration lab (five workflow patterns, a free agent, a crash and resume, one agent against several) and the Production stack (a gateway, traces, an eval gate and hosted runtimes around it).

New terms (each defined again where it is used):

Workflow
model calls along code paths you wrote; your code picks the next step.
Agent
the model picks the next step, turn after turn, until it stops.
Framework
any library that writes some of the loop, its state or its plumbing for you.
Checkpoint, thread id
the run's whole state saved after a step, under the id that names the run; resuming loads the newest one.
Structured output
the model's answer as data that matches a schema, not free text.
Gateway
a proxy between your code and the model providers: one API, keys, budgets, retries, fallbacks.
Trace, span
one run recorded as a tree of timed steps (model calls, tool calls) with tokens and cost.
Hosted runtime
the vendor runs the loop, the sandbox and the session; you send a task and receive events.

The libraries compared

What each makes you describe, what it gives you over a plain loop, and what it costs. First-request sizes are the Same agent tab's: the same task, the same four tools and the same short system prompt, on a local 4B model (Qwen tokenizer); the Claude Agent SDK row is Claude's tokenizer, so compare it only within its row MEASURED.

Library (school)You describeGives you over a plain loopCosts youOwner page
Plain loopevery call, schema and stop rulenothing hidden: the request is the dictionary you builtyou build every feature below; first request 397 tokensBuilding a harness
LangGraph (graph)a typed state, nodes and edgesa checkpointer: resume after a crash, human pauses, time travelconcepts and ceremony; first request 385LangChain and LangGraph
Pydantic AI (typed loop)a typed function and an output_typetool schemas from signatures, validated results, ModelRetryan extra output tool; first request 507Typed agent libraries
OpenAI Agents SDK (typed loop)agents, tools, handoffshandoffs, guardrails, sessions, tracingtracing on by default to OpenAI; first request 491Typed agent libraries
smolagents (typed loop)tools as Python functionscode actions: several tool calls and a loop in one stepa sandbox for model-written code; first request 2,231Typed agent libraries
Google ADK (typed loop)agents and sub-agentsfive languages, A2A, Google Cloud deploymentnot in the six-way runTyped agent libraries
Claude Agent SDK (harness)options for a finished agentClaude Code's loop, tools, compaction, permissions, sessionsClaude only; first call 1,388 with our prompt, 7,612 with Claude Code's, 13,002 with its toolsClaude Agent SDK
CrewAI, Microsoft Agent Framework (roles)a cast of roles, goals and tasksa multi-role system sketched quicklyprompts you did not write; agents talking to each other; not run herethis page, section 2

The other layers are compared on their own pages: gateways (LiteLLM, OpenRouter, Portkey, Envoy) on Gateways and routing section 11, tracing tools (Langfuse, LangSmith, Braintrust, Phoenix) on LLM observability section 5.

Who writes each piece, by position on the axis

Every library sits on one line, from You own the loop (plain API calls) to The vendor owns the loop (a hosted runtime, section 9). Fig. 2 takes the nine pieces of an agent along it, one position per step: blue, you write it; grey, the library provides it; purple, the vendor runs it. Moving right buys features with control.

Predict first: moving right from a plain loop, at which position does crash recovery stop being your job?

  1. Plain API calls (the provider SDK, a while loop or your own DAG engine). All nine pieces are yours: the loop in about 15 lines, hand-written JSON schemas, persisting messages, pausing, trimming, tools, sandbox, and your process runs it. Everything is visible and nothing is hidden: the request is exactly the dictionary you built. The Same agent tab's version 1 is this position.
  2. Minimal loop library (Pydantic AI, OpenAI Agents SDK, smolagents, Google ADK). The loop (an Agent and run()), the tool schemas (from type hints or docstrings) and the order of steps (the model, plus handoffs or agents-as-tools) move to the library. Sessions keep history, but crash recovery, approval, compaction, tools and the sandbox stay yours. Prompt inflation starts here: the framework adds instructions or tools you did not write.
  3. Graph runtime (LangGraph, LlamaIndex Workflows). Saved state and the human pause move to the library: a checkpointer after every step, interrupt() and resume. The order of steps comes back to you as the graph you declare; the runtime runs it. Crash recovery, human pauses of any length and replay from an old step come with it (section 3).
  4. Harness as a library (Claude Agent SDK). Everything but where it runs moves to the library: Claude Code's loop, @tool served in-process, sessions you can resume, a permission callback you write, automatic compaction, Read, Edit, Bash and Grep, permission modes and an optional OS sandbox. You configure a finished agent instead of assembling one; the loop is only as open as its settings.
  5. Hosted runtime (OpenAI Agents API, Claude Managed Agents). The vendor runs eight of the nine pieces on its servers; you only declare your custom tools. What you give up is exactly control flow and visibility: what you trace is what the vendor exports (section 9).
Answer, and all nine pieces at all five positions (the table behind Fig. 2)

Crash recovery arrives with the graph runtime (step 3): the minimal loops keep sessions (history), which is not resuming a half-finished run. The cells are this page's reading of each library's documentation; a library can usually be configured to hand a piece back to you.

PiecePlain API callsMinimal loop libraryGraph runtimeHarness as a libraryHosted runtime
The loop (call, run tool, repeat, stop)you write it (about 15 lines)Agent + run()prebuilt agent node, or your own nodesClaude Code's loopthe vendor's
Tool schemashand-written JSON schemafrom type hints or docstringsfrom type hints@tool, served in-processyou declare your custom tools
Order of stepsyour code, or the model inside your loopthe model, plus handoffs or agents-as-toolsyou declare the graph; the runtime runs itthe modelthe vendor's harness
Saved state, resume after a crashyou persist messages yourselfsessions keep history; crash recovery is mostly yourscheckpointer after every stepsessions you can resumedurable sessions on their side
Pause for a humanyou block or save and resumesome offer approval hooks; you wire theminterrupt() and resumea permission callback you writeserver-side permission policies
Context trimming and compactionyou trimmostly yoursyours, with middleware hooksautomatic compactionthe vendor compacts
Built-in tools (files, shell)you write themyours (smolagents ships a few)yoursRead, Edit, Bash, Grep and moreprovided
Permissions and sandboxyouyours; smolagents offers sandboxed executorsyourspermission modes and rules; optional OS sandboxtheir policies, their or your sandbox
Where the loop runsyour processyour processyour process, or their hosted platformyour process or containerthe vendor's servers
The one idea to keep
For the running example, two plain model calls glued by 20 lines of script fixed the visible tests in 19.4 s for $0.013, and a free agent did it in 24.8 s for $0.030 MEASURED. Neither needed a framework. Start there, and add one when a section below names a need you have.
The chain's five steps were written before the run; the agent chose its own and paid for re-sending its growing conversation

Workflow: prompt chaining

Agent: the model chooses

1. Workflows or agents: who picks the next step?

Anthropic's Building effective agents (Erik Schluntz and Barry Zhang, 19 Dec 2024) SOURCE draws the line every framework sits on. A workflow is a system where model calls and tools are "orchestrated through predefined code paths"; an agent is one where models "dynamically direct their own processes and tool usage". The same post names five workflow patterns, the shapes most production "agents" really are:

  • Prompt chaining: a fixed sequence of calls, each reading the last one's output, with code checks (gates) between them.
  • Routing: one call classifies the input and sends it to a specialised prompt or model.
  • Parallelisation: independent calls at once, merged by code (sectioning), or the same call several times and a vote.
  • Orchestrator-workers: a model writes the plan at run time, workers carry out the pieces, a model combines them.
  • Evaluator-optimizer: one call produces, another critiques, until the critic is satisfied or a round limit hits.

The same input both ways, recorded on 5 October 2026 with Claude Haiku 4.5 MEASURED. Left: a two-call chain where a script does the reading, gating, writing and testing. Right: the same model inside Claude Code with Read, Edit, Bash and friends, given only the prompt. Predict which one processes more tokens; the replay plays when it scrolls into view, one step of each lane at a time.

  1. Diagnose; look around. Workflow: model call 1, a diagnosis, with core.py and the test output pasted in by the script. Agent: the model asks Bash for ls -la.
  2. A gate; an error. Workflow: a code gate checks that the diagnosis names every failing test. Agent: Read on the directory /work returns an error (EISDIR); the model reads it and tries something else, which no workflow author planned for.
  3. Fix; find the files. Workflow: model call 2 writes the fixed functions. Agent: Glob **/* lists the repository.
  4. Write; read the tests. Workflow: plain code writes core.py. Agent: it reads tests/test_core.py.
  5. Test; read the code. Workflow: plain code runs the tests and the six hidden checks, and the chain is finished. Agent: it reads textstats/core.py.
  6. The agent reads on. README.md, a step nobody asked for and nobody forbade.
  7. It runs the tests itself. Bash python3 tests/test_core.py: exit code 1, both failures in front of it.
  8. First edit. An exact-string replacement in core.py, chosen by the model.
  9. Second edit. The other bug, the same way.
  10. It checks its own work. The tests again: they pass.
  11. Both done. The chain ran the five steps its author wrote, two of them model calls; the agent chose 10 tool calls over 11 turns. Both passed the visible tests and 5 of 6 hidden checks; the totals under the lanes show what each processed.

The chain's cost and time are known in advance and every step is auditable, but it can only do what its author foresaw (it pasted core.py in because the author knew the bug was there). The agent found the files itself, tripped over a directory read, ran the tests, edited twice and verified, and processed many times more tokens for a similar result. Of the six designs in the lab, only routing (6 of 6 hidden checks, 55.7 s) and the evaluator-optimizer (6 of 6, 262.7 s) passed every hidden correctness check; the others passed 5 of 6 and the unfixed code 3 MEASURED. Both carried more knowledge of what "correct" means, a specialist prompt or an edge-case reviewer: information and verification bought correctness, not the shape of the graph.

Choose a workflow when the steps are known, cost and latency must be bounded, an auditor will ask why each step ran, or the model is weak at choosing. Choose an agent when the number and kind of steps depend on what is found: debugging, research, anything open-ended. Anthropic's advice is "the simplest solution possible, and only increasing complexity when needed"; most real systems mix the two.

Go deeper. The Orchestration lab runs all five patterns and the free agent on this input, replays each on a clock with cost and tokens, and runs any two side by side. How the agent loop itself works: Building a harness and the harness root's Loop lab; the paper it descends from: ReAct. When several agents beat one workflow: Multi-agent patterns, section 4.

2. The orchestration schools

Orchestration libraries differ less in what they can do (all of them can call tools in a loop) than in what they make you describe: a graph, a cast of roles, a typed function, or the options of a finished agent. One paragraph each, with what it costs you; the comparison table above puts them side by side.

Graph and state machine: LangGraph, LlamaIndex Workflows

LangGraph models an application as a StateGraph: a typed state object, nodes that are plain functions returning updates to it, and edges (fixed, or functions that route on the state). Its reason to exist is the checkpointer of section 3. LangChain's create_agent runs on it (LangChain blog, 1.0 of both on 22 October 2025) SOURCE. LlamaIndex Workflows is the event-driven version: "an event-driven, step-based way to control the execution flow" (docs), where steps react to typed events instead of declared edges. Costs you: ceremony (state schema, nodes, edges, compile) for what may be a 15-line loop, and a large dependency. Pays when: runs must survive crashes, pause for people, branch and merge. Super-steps, checkpointers, interrupts, LangChain's Runnables and when a graph beats a plain loop, each measured: LangChain and LangGraph.

Roles and crews: CrewAI, AutoGen, AG2, Microsoft Agent Framework

This school has no child page; this section owns it. CrewAI describes a system as agents with a required role, goal and backstory, tasks assigned to them, and a sequential or hierarchical process; for fixed pipelines it adds event-driven Flows (docs) SOURCE. The prompts are generated from those fields, which makes a system quick to sketch and hard to control precisely. AutoGen made multi-agent work a conversation between agents; its repository now says "AutoGen is now in maintenance mode" and names the Microsoft Agent Framework as its successor, which Microsoft describes as "the next generation of both Semantic Kernel and AutoGen" (AutoGen, Microsoft Learn); its 1.0 releases for Python and .NET were tagged on 2 April 2026 SOURCE. AG2 continues the AutoGen line separately ("AG2 (formerly AutoGen)", repo). Costs you: prompts you did not write and many model calls spent on agents talking to each other. Pays when: the problem really is several roles, and you value speed of sketching over control. The versions checked are in the closed table of Typed agent libraries.

Minimal typed loops: Pydantic AI, OpenAI Agents SDK, smolagents, Google ADK

The same small shape: an Agent object with instructions and tools, and a run function that loops. What distinguishes them: Pydantic AI validates results against an output_type and sends a ModelRetry back to the model as a retry prompt; the OpenAI Agents SDK adds handoffs, guardrails and sessions, with tracing to OpenAI's dashboard "enabled by default" (docs); smolagents changes the action language, its CodeAgent writing Python that is executed (the CodeAct paper reports "up to 20% higher success rate" than JSON actions, Wang et al., 2024), so it needs a sandbox; Google ADK is "available in Python, TypeScript, Go, Java, and Kotlin" and speaks A2A (adk.dev) SOURCE. Costs you: prompt inflation, tokens you never wrote. On the same task and tools the first request ran from 385 tokens (LangGraph) to 2,231 (smolagents, its own code-action system prompt), against the plain loop's 397 MEASURED; the table above has each. Pays when: you would otherwise hand-roll and want typed tools and results for little code. Each library read from its source and run, compared axis by axis: Typed agent libraries.

Harness as a library: the Claude Agent SDK

The Claude Code SDK was renamed the Claude Agent SDK on 29 September 2025 (Anthropic) SOURCE. It ships Claude Code's whole loop as a library: your program starts the Claude Code binary and answers its questions on a pipe. You configure an agent rather than assemble one. Costs you: Claude models only, and Claude Code's own context (the table's first-call sizes); without strict_mcp_config=True a subscription run also loaded the account's connectors, well over 100,000 tokens of tool definitions MEASURED. Pays when: the job is work on a computer (files, shell, code) and you want a mature loop with compaction and permissions without writing them. The pipe, every default that bites, permissions, sessions and cost, each in a recorded run: Claude Agent SDK.

Go deeper. Same agent, six ways: one agent written in a plain loop, LangGraph, Pydantic AI, the OpenAI Agents SDK, smolagents and the Claude Agent SDK, each run for real, with the exact request each framework sent and how each adds approval and a retry.

3. State, durability and humans in the loop

The state of a run is everything needed to carry on: the messages so far, intermediate results, which step comes next. In a plain script it lives in one process's memory; kill the process (a deploy, an out-of-memory kill, a closed laptop) and the run is gone, including the model calls already paid for. Agents make this the normal case: runs last minutes to hours, and some must wait days for a person.

The fix is a checkpoint: after every step, write the whole state to a database under a thread id; to recover, load the newest checkpoint of that thread and continue from the next step. Two features fall out of the same mechanism: a human-in-the-loop interrupt (save, exit, resume later with the person's answer) and time travel (load an older checkpoint, edit it, run forward on a new branch). The Orchestration lab did all three with a LangGraph StateGraph and a SQLite checkpointer MEASURED; Fig. 3 replays that recording.

  1. One graph, five nodes. The lab's prompt chain rebuilt as a StateGraph: read + test and apply + test are plain code, diagnose and propose fix are model calls (Claude Haiku 4.5), human review is an interrupt. Process 1 calls invoke({}, thread "fix-1").
  2. A checkpoint after every node. Diagnose finishes after 12.6 s ($0.0072). Before the next node starts, LangGraph writes the state to SQLite under the thread id: four rows by now.
  3. SIGKILL, 3.1 s into the fix call. The process dies; the model call in flight is paid for and its answer lost. The four rows survive in the SQLite file.
  4. Resume from the newest row. Process 2 calls invoke(None, thread "fix-1"): LangGraph loads the newest checkpoint, whose next node is propose fix, and runs it (10.8 s). The diagnosis is not paid for twice; the call in flight was lost and made again.
  5. Pause for a person, resume with the answer. Human review calls interrupt(): the state and the pending question are saved and process 2 exits. Process 3 resumes with the answer "approve"; the node runs again from its first line, then apply + test passes.
  6. Rewind and fork. Process 4 edits the checkpoint saved after diagnose and runs forward on a new branch, the second row; process 5 approves it. The first branch stays untouched: eleven rows in all.
  7. The other family: an event history (a picture, not a run: Temporal was not run here). Temporal records every completed activity and, after a crash, re-runs the workflow code from the top, replaying the recorded results instead of calling the model again; so the workflow code must be deterministic.

Two families of durability, compared side by side in the lab. Checkpointing (LangGraph and most agent libraries) saves a snapshot of state after each step. Durable execution engines such as Temporal save an event history of every completed activity and, after a crash, re-run your workflow code from the top, replaying recorded results instead of calling again; in exchange, the workflow code must be deterministic. If your company already runs Temporal or a job system, one model call per activity gives an agent durability without an agent framework. Across the schools: the graph runtimes give crash recovery with no extra work; the minimal loops give sessions (history), which is not resuming a half-finished run; the Claude Agent SDK resumes and forks sessions; a hosted runtime keeps sessions on the vendor's side. Nothing restarts a dead process for you: a job queue, a supervisor or a hosted platform has to call resume with the same thread id.

Go deeper. Orchestration lab, part "Durable execution": the kill, resume, interrupt and fork replayed from the recorded checkpoints, and the checkpointer against Temporal. LangGraph's own mechanics, each measured on LangChain and LangGraph: super-steps and pending writes, which let a finished parallel task survive a SIGKILL (sections 3 and 5); what a checkpoint holds and how big it grows (section 4); the three durability modes and what each leaves after a kill (section 5); interrupts, and why a resumed node runs again from its first line, so a side effect before the pause must be safe to repeat (section 6).

4. Structured output and typed tools

Code downstream needs fields, not prose. Structured output is getting the model's answer as data that matches a schema (usually JSON Schema), and typed tools are the same idea for tool arguments. Three ways, from weakest to strongest:

  1. Ask in the prompt and parse. Works most of the time; fails on fences, preambles, trailing commas, a missing field.
  2. Make the answer a tool call. Offer one tool whose input schema is your result type and require the model to call it; tool-calling models are trained to emit arguments that fit, and the harness validates them (Pydantic AI's output tool, the Claude Code CLI's --json-schema).
  3. Constrain the decoding. The provider only lets the model produce tokens that keep the output valid (OpenAI's strict mode, function calling guide, read 5 Oct 2026 SOURCE). Validity is guaranteed; whether the content is right is not, and the server must support it.

This page recorded the first two once on the running example (Claude Haiku 4.5, every built-in tool off, 6 October 2026) MEASURED: both answers named the right bugs, but the prompt-only reply wrapped its JSON in a Markdown fence, so json.loads on the raw text failed at the first character; --json-schema returned a parsed object for one more turn and a larger first request. The usual repair is validate-and-retry: check the parsed object against the schema and, on failure, send the error back and ask again, a bounded number of times, counting every retry.

Go deeper. Typed agent libraries: how a function becomes a tool schema (section 1), where the result schema travels in each library (tool, native, prompted), measured on a local model and on Claude, where the fence turned out to be Haiku's habit (section 2, and its Output modes lab), and validate-and-retry with dependencies (section 3). Constrained decoding itself: Sampling and Decoding.

5. Multi-agent: when it helps and when it hurts

A multi-agent system is several model loops cooperating, each with its own prompt, tools and context window: a lead with workers, handoffs between specialists, a shared blackboard, a debate or a vote. The one distinction that decides most cases: parallel reading (search, research, review) splits well, because the pieces need not agree; parallel writing of one artefact does not, because each writer makes decisions the others cannot see. That reconciles the two published positions of June 2025, Anthropic's multi-agent research system (for, on breadth-first research) and Cognition's Don't Build Multi-Agents (against, on writing), in Philipp Schmid's read and write framing SOURCE.

On the running example, a small coding task, the Orchestration lab ran the same model alone and as a lead with two investigating subagents MEASURED: the same fix and the same hidden-check score (5 of 6), for 438,517 tokens against 120,530 and 68.4 s against 24.8 s. The subagents re-read files the lead had already read, and the lead waited for them. Most published evidence for multi-agent gains is vendor-run on internal evaluations; say who ran a number before quoting it.

Go deeper. Multi-agent patterns owns the taxonomy and the evidence: every shape on a task that fits it, with its cost (sections 1 to 8), token and quality accounting (section 9), the published evidence read carefully (section 10: Anthropic's 90.2%, Kim et al.'s 260 configurations, MAST's failure modes, debate against voting) and when several agents beat one (section 11). The recording above, lane by lane with each agent's context size: Orchestration lab, part "One agent or several".

6. Gateways

Once more than one team or one provider is involved, every agent needs the same plumbing around each model call: credentials, a request format per provider, retries when a provider returns 429 (rate limited) or 5xx (server error), a fallback model when one is down, a timeout, a spend limit and a log line. A gateway (an LLM proxy) does all of it in one place: your code calls one OpenAI-shaped endpoint, and model choice, keys and spend become configuration instead of code. The two poles: LiteLLM, self-hosted, one endpoint over "100+ LLM providers" with virtual keys, budgets and a router (repo; the old page notes Khalid runs it at work), and OpenRouter, managed, one key and one bill over "400+ AI models" (FAQ) SOURCE; they compose, since LiteLLM can use OpenRouter as one more upstream. On 19 Aug 2026 OpenRouter announced it is "joining forces with Stripe", subject to closing conditions, with no price disclosed (announcement) SOURCE.

The cross-cutting risk is a fallback you never evaluated: the same prompt behaves differently on another provider's model, so during an outage the agent keeps answering, worse, and nothing errors. Run your evals against every model in the fallback chain (section 7) and tag each trace with the model that actually answered.

Go deeper. Production stack: a LiteLLM proxy run in front of a deliberately failing provider and a local model, the same failure with and without a gateway, virtual keys, and a simulator of a hundred requests through a bad afternoon. One call inside LiteLLM read from its source and recorded attempt by attempt: Gateways and routing (choosing a deployment, section 2; retry, cool down or fall back, 3; retries multiplying across layers, 4; rate limits, 5; budgets, 6; the response cache, 7; format translation, 8; OpenRouter's provider market, 9; routers and cascades, 10; the tools compared, 11).

7. Observability and evals

You cannot debug an agent from log lines: you need to see which call saw what. Every tool converges on one data model. A trace is one run; it holds a tree of spans (timed units of work: a model call, a tool call, a subagent), each with attributes such as the model, token counts and cost. OpenTelemetry's GenAI semantic conventions standardise the names (gen_ai.operation.name with invoke_agent, chat or execute_tool, gen_ai.usage.input_tokens and so on); they are still marked "Development" (semantic-conventions-genai, read 6 Oct 2026) SOURCE. Backends (Langfuse, LangSmith, Braintrust, Arize Phoenix) differ by what they put first, tracing or evals, and all accept OpenTelemetry.

Evals in the loop close the circle: score a sample of production traces with rules and model judges, turn the interesting ones into dataset items, and run that dataset before every prompt, model or framework change; attribute cost per run, user and feature from the spans and reconcile it against the gateway's spend records. The Production stack's eval gate does this on recorded runs of the running example, with no model in the loop.

Go deeper. Production stack: GenAI spans for a real agent run, collected locally and drawn as a tree, cost attributed span by span, and the eval gate. LLM observability: traces and spans (section 1), the conventions attribute by attribute (2), one run instrumented eight ways (3, and its Eight instrumentations tab), Langfuse self-hosted (4), the tools compared by design (5), cost reconciled to the cent (6), sampling (7), personal data in traces (8), evals on traces (9). How to grade agent runs: Agent and trajectory evaluation.

8. Memory

Memory that outlives a session (Mem0's extracted facts, Zep's temporal graph, Letta's paged context, and a twelve-session experiment that ran all three) is taught on Context engineering, section 8, in Topic: agentic-harnesses; the former child page Agent memory layers was merged into it on 24 October 2026.

9. Hosted runtimes: buying the loop

The far end of the axis: the vendor runs the loop, the sandbox and the session on its servers, and you send a task and receive events. Claude Managed Agents is a "pre-built, configurable agent harness that runs in managed infrastructure", in public beta since 8 April 2026 (overview), with permission policies always_allow, always_ask and (since 10 Sep 2026) auto (permission policies). OpenAI's Agents API entered public beta on 10 Sep 2026: a "managed Codex harness while OpenAI handles session orchestration, context compaction, and recovery" (changelog) SOURCE. It builds on the Responses API (March 2025), which already ran built-in tools on OpenAI's side. What you trade: no loop to operate, durable sessions and sandboxes included; in exchange, control flow and prompts are the vendor's (factors 2 and 8 of the twelve in section 10), the spans between your request and your result are whatever the vendor exports, your data and tools run where the vendor runs them, and moving to another model means moving off the product.

Go deeper. Production stack, part "Hosted runtimes": the two compared row by row, with Anthropic's session-hour price worked through. Managed Agents next to building a product on the SDK: Claude Agent SDK, section 10.

10. How to choose

The default, argued by Anthropic's post and by HumanLayer's 12-factor agents SOURCE: start with direct API calls behind your gateway, and adopt a framework when a specific capability would otherwise be built by hand. A hand-built engine that runs a graph of model calls, such as the DAG engine Khalid wrote, is already the workflow half of this spectrum; what LangGraph would add to it is the checkpointer, interrupts and replay. Answer the five questions in the chart beside this text; the rules behind the answer are printed with it.

The twelve factors, as titled in the repository, are a checklist for any position on the axis: 1 Natural language to tool calls; 2 Own your prompts; 3 Own your context window; 4 Tools are just structured outputs; 5 Unify execution state and business state; 6 Launch, pause, resume with simple APIs; 7 Contact humans with tool calls; 8 Own your control flow; 9 Compact errors into the context window; 10 Small, focused agents; 11 Trigger from anywhere, meet users where they are; 12 Make your agent a stateless reducer. Factor 4 is section 4's tool route, factor 6 is section 3's checkpoint, factor 10 is section 5's warning. A framework that hides your prompt (factor 2) or your loop (factor 8) must pay for it with something on this list.

Look at the request, whatever you choose
Hamel Husain's "Show me the prompt" (14 Feb 2024): intercept and read what the framework actually sends. The Same agent tab does exactly that with a logging proxy.
Five answers pick a position on the axis; each rule names the section it comes from

11. Child pages

Six pages own the depth, each built from its own recordings and primary sources (October 2026). Reading times are each page's own measurement. The sibling root, Topic: agentic-harnesses, has its own seven; none of these repeats them.

LangChain and LangGraph: graphs, state, checkpointers, interrupts, durable executionLangChain's Runnables and their cost, a graph from zero, super-steps, checkpointers and what survives a SIGKILL, interrupts and Command, streaming, subgraphs, create_agent and middleware, the store, and when a graph beats a plain loop. Reading 35 min, plus 10 in closed details.
Claude Agent SDK: the Claude Code loop as a libraryYour program starting the Claude Code binary and talking to it on a pipe: the defaults that bite, tools, permissions and hooks as your functions, subagents, sessions, structured output, cost accounting, a product on it; tabs Options lab, Recordings. Reading 30 min, plus 10 in closed details.
Typed agent libraries: Pydantic AI, OpenAI Agents SDK, smolagents, Google ADKFive libraries compared by design axis: function to tool schema, where the result schema travels, validate and retry, each loop and its caps, handoffs as tools, guardrails and state, tracing defaults, choosing; tabs Output modes lab, Mechanisms, recorded. Reading 28 min, plus 6 in closed details.
Multi-agent patterns: orchestrator-workers, handoffs, debate, when several agents help or hurtEvery shape on a task that fits it, with its cost: an audit too big for one window, blackboard, handoffs against agents-as-tools, two writers on one feature, debate against voting, the published evidence and MAST's failure modes; tab Audit lab. Reading 32 min, plus 14 in closed details.
LLM observability: traces, OpenTelemetry GenAI, Langfuse and peers, evals in the loopTraces and spans, the GenAI conventions attribute by attribute, one run instrumented eight ways into a self-hosted Langfuse, the tools by design, cost reconciled, tail sampling, redaction, evals on traces; tab Eight instrumentations. Reading 35 min, plus 9 in closed details.
Gateways and routing: LiteLLM, OpenRouter, fallbacks, budgets, rate limitsOne call inside LiteLLM from its source and recordings: deployment choice, retries, cooldowns and fallbacks, retries across layers, rate limits, budgets, the cache and its semantic-cache risks, translation, OpenRouter, routers and cascades, the tools compared. Reading 39 min, plus 17 in closed details.

Agent memory layers is no longer a child of this topic: it was merged into Context engineering (section 8) on 24 October 2026.

Depth: interview rehearsal

Nine questions this topic should let you answer (closed; answer aloud first, then open each)
Workflow or agent: define both and say when you pick each.
A workflow runs model calls along code paths you wrote; an agent lets the model choose each next step until it stops. Pick a workflow when steps are known and cost, latency and audit matter; an agent when the steps depend on what is found.
What does LangGraph give you that a while loop does not?
State saved after every step under a thread id: resume after a crash, human interrupts of any length, replay or fork from an old step, plus merge rules for parallel branches. Nothing else that a loop cannot do.
How do you get reliable structured output from a model?
Offer the schema as a tool or use constrained decoding, validate the result against the schema in code, and on failure send the validation error back for a bounded number of retries, counting them as a metric.
Your agent must wait two days for a manager's approval. Design it.
Checkpoint state to a durable store under a thread id; the approval request carries the id; exit; on approval, a worker reloads and resumes. Side effects after the approval only, or idempotent. A supervisor or queue restarts failed resumes.
When does multi-agent help?
Breadth-first reading that exceeds one context (research, search, review) with independent subtasks and a value that justifies several times the tokens. Not for one artifact many agents would write.
What does a gateway do and what can go wrong with fallbacks?
One endpoint, keys, budgets, rate limits, retries, fallbacks, logging. A fallback model that was never evaluated degrades quality silently; eval every model in the chain and tag traces with the model that answered.
What is in a trace of an agent run?
A root span for the run, child spans per model call (model, tokens, cost) and per tool call (name, arguments, result, error), nested subagent subtrees, all with timings, ideally with OpenTelemetry GenAI attribute names.
Fact memory or temporal graph?
Facts (Mem0 style) are compact and simple; a temporal graph (Zep style) keeps when each fact was true, so it can answer "what was true in March" and supersede instead of overwrite. Paging (Letta) lets the agent manage its own context. The measured comparison is on Context engineering, section 8.
Build, adopt a framework, or buy a hosted runtime?
Build when the loop is your product or must run in an unusual place; adopt a framework for durability or typing you would get wrong; buy when you do not want to operate sandboxes and sessions and accept the vendor's control flow, models and trace export.

Reading tab notes, data and checks: src/read/ (extract_read.py, check_read.py, coverage.md, viz_ideas.md); the rebuild of 24 October 2026 is described in src/README.md. The old Notion root and its four children are saved verbatim in src/read/old/.