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.
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.
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):
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 describe | Gives you over a plain loop | Costs you | Owner page |
|---|---|---|---|---|
| Plain loop | every call, schema and stop rule | nothing hidden: the request is the dictionary you built | you build every feature below; first request 397 tokens | Building a harness |
| LangGraph (graph) | a typed state, nodes and edges | a checkpointer: resume after a crash, human pauses, time travel | concepts and ceremony; first request 385 | LangChain and LangGraph |
| Pydantic AI (typed loop) | a typed function and an output_type | tool schemas from signatures, validated results, ModelRetry | an extra output tool; first request 507 | Typed agent libraries |
| OpenAI Agents SDK (typed loop) | agents, tools, handoffs | handoffs, guardrails, sessions, tracing | tracing on by default to OpenAI; first request 491 | Typed agent libraries |
| smolagents (typed loop) | tools as Python functions | code actions: several tool calls and a loop in one step | a sandbox for model-written code; first request 2,231 | Typed agent libraries |
| Google ADK (typed loop) | agents and sub-agents | five languages, A2A, Google Cloud deployment | not in the six-way run | Typed agent libraries |
| Claude Agent SDK (harness) | options for a finished agent | Claude Code's loop, tools, compaction, permissions, sessions | Claude only; first call 1,388 with our prompt, 7,612 with Claude Code's, 13,002 with its tools | Claude Agent SDK |
| CrewAI, Microsoft Agent Framework (roles) | a cast of roles, goals and tasks | a multi-role system sketched quickly | prompts you did not write; agents talking to each other; not run here | this 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.
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?
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.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).@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.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.
| Piece | Plain API calls | Minimal loop library | Graph runtime | Harness as a library | Hosted runtime |
|---|---|---|---|---|---|
| The loop (call, run tool, repeat, stop) | you write it (about 15 lines) | Agent + run() | prebuilt agent node, or your own nodes | Claude Code's loop | the vendor's |
| Tool schemas | hand-written JSON schema | from type hints or docstrings | from type hints | @tool, served in-process | you declare your custom tools |
| Order of steps | your code, or the model inside your loop | the model, plus handoffs or agents-as-tools | you declare the graph; the runtime runs it | the model | the vendor's harness |
| Saved state, resume after a crash | you persist messages yourself | sessions keep history; crash recovery is mostly yours | checkpointer after every step | sessions you can resume | durable sessions on their side |
| Pause for a human | you block or save and resume | some offer approval hooks; you wire them | interrupt() and resume | a permission callback you write | server-side permission policies |
| Context trimming and compaction | you trim | mostly yours | yours, with middleware hooks | automatic compaction | the vendor compacts |
| Built-in tools (files, shell) | you write them | yours (smolagents ships a few) | yours | Read, Edit, Bash, Grep and more | provided |
| Permissions and sandbox | you | yours; smolagents offers sandboxed executors | yours | permission modes and rules; optional OS sandbox | their policies, their or your sandbox |
| Where the loop runs | your process | your process | your process, or their hosted platform | your process or container | the vendor's servers |
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:
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.
core.py and the test output pasted in by the script. Agent: the model asks Bash for ls -la./work returns an error (EISDIR); the model reads it and tries something else, which no workflow author planned for.**/* lists the repository.core.py. Agent: it reads tests/test_core.py.textstats/core.py.README.md, a step nobody asked for and nobody forbade.python3 tests/test_core.py: exit code 1, both failures in front of it.core.py, chosen by the model.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.
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.
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.
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.
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.
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.
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.
invoke({}, thread "fix-1").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.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.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.
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:
--json-schema).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.
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.
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.
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.
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.
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.
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.
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.
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.Agent memory layers is no longer a child of this topic: it was merged into Context engineering (section 8) on 24 October 2026.
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/.
An agent is a model in a loop: send the conversation and a list of tools, get back either an answer or a request to run a tool, run it, append the result, repeat. That loop fits in about fifteen lines. A framework is a library that writes that loop for you and adds things around it (tool schemas from type hints, saved state, retries, typed results, tracing, approval steps). This tab builds the same agent six times, runs every version for real, and shows what each framework did for you, what it sent to the model on your behalf, and where it got in the way.
Task (the running example of both agent topics): a tiny Python library, textstats, with two planted bugs (the tokenizer drops apostrophes, so word_count("don't stop") is 3 instead of 2; top_words breaks ties by order of appearance, not alphabetically). 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." One task for all six: every framework here can call tools, so a coding task with a test runner as the judge works for all of them.
Tools, identical in all six (the same Python bodies are imported by every version, so only the framework differs): list_files(), read_file(path), edit_file(path, old, new) (exact-string replace, as real harnesses do) and run_tests(). Same short system prompt, same limit of 15 model calls.
Models. Versions 1 to 5 talk to an OpenAI-compatible endpoint served on this laptop: local model on Apple M1 Pro mlx-community/Qwen3-4B-Instruct-2507-4bit (a 4-billion-parameter open model, 4-bit weights) served by mlx_lm.server (mlx-lm 0.32.0), through a logging proxy that saved every request byte for byte. Version 6 cannot use that endpoint (the Claude Agent SDK drives Claude Code, which talks to Anthropic), so it runs Claude Haiku 4.5 and Sonnet through a Claude subscription. The two are never compared as if they were the same model: a 4B local model failing where Claude succeeds says nothing about the frameworks.
Pass means: the test file is unchanged and python3 tests/test_core.py passes afterwards, checked by the runner, not by the agent's own claim. All runs on 2026-10-05; package versions pinned below each code panel.
Pick any two versions. Colour marks the part of the agent each line plays; click a role to light up the same part in both panels. Lines of code count non-blank lines that are not comments or docstrings; the shared tool bodies (tools_impl.py, below) are not counted for anyone.
tools_impl.py) and the two Claude variantsVariant 6b keeps the four tools but asks for Claude Code's own system prompt with ours appended; variant 6c drops our tools and uses Claude Code's built-in Read, Edit, Bash, Glob and Grep, which is how most people use the SDK. Both are used only in section 3.
Each local version ran once with greedy decoding (temperature 0, the server default, so a rerun gives nearly the same trajectory) and three more times sampling at temperature 0.7 to show the spread. Claude versions ran three times on Haiku and once on Sonnet. A dot per run: ● fixed, ○ not fixed. Times are wall-clock on the laptop (local) or reported by Claude Code (duration_ms), so the two columns are not comparable either.
Every framework turned the same intent (system prompt, task, four tools) into an HTTP request. The proxy saved the first request of each run. The figure builds both requests block by block, drawn to scale (one square per 10 prompt tokens, as counted by the server's tokenizer); the difference is prompt inflation: tokens you pay for on every call that you never wrote. Pick another framework and it builds again.
The same measurement on the Claude side, where the request itself cannot be captured (it goes from Claude Code to Anthropic) but every response reports the input tokens it was charged for. Same task, same four tools, Haiku 4.5, first call:
Token counts from the first assistant message's usage (input plus cache writes plus cache reads). Claude's tokenizer is not Qwen's, so compare these bars only with each other. The 6c bar is Claude Code's real built-in tool set and prompt: what the SDK sends when you do not override it.
Step through any recorded run call by call (pick the run above the replay; it opens on the run's first call). The strip on top is the context the model saw on that call, one square per 25 prompt tokens: watch it grow as every tool result is appended, which is why the last calls of a run cost the most. A replay is a tool to drive, so it does not play by itself; the caption under the strip says what the model asked for on each call.
Read from each library's installed source (versions above) and its docs on 2026-10-05. "Approval" is a human saying yes before edit_file runs; "retry" covers the two kinds every agent needs: a transient API failure (retry the same call) and a model mistake (tell the model what went wrong and let it try again).
openai client retries connection errors, 429 and 5xx responses twice by default (DEFAULT_MAX_RETRIES = 2 in openai 3.24.0's _constants.py).if call.function.name == "edit_file" and input(f"Allow {args}? ") != "y":
result = "denied by the user" # the model sees the refusalThe pause blocks the process: fine for a CLI, not for a web service, where you must save messages and resume later yourself.OpenAI(max_retries=5). Model mistakes: already there, the except turns a bad call into an observation.ToolNode runs every tool call and appends the results; the checkpointer saves the whole state after every step under a thread_id, so a run can be paused, inspected, resumed or replayed (persistence docs).required lists). The cost is concepts: state reducers, conditional edges, recursion_limit counting graph steps rather than model calls (15 model turns needed a limit of 31). create_react_agent, the one-line version, warns in 1.2.13 that it is deprecated in favour of LangChain's create_agent.g.compile(checkpointer=InMemorySaver(),
interrupt_before=["tools"])
# run stops before tools; a human looks, then:
app.invoke(None, config) # resumeor call interrupt(...) inside a node and resume with Command(resume=...) (interrupts docs). Works across processes because the state lives in the checkpointer.g.add_node("agent", agent, retry_policy=RetryPolicy()): defaults 3 attempts, 0.5 s then doubling (langgraph/types.py). Tool argument errors go back to the model as a message by default; other tool exceptions are raised.FixReport), usage limits, and ModelRetry: raise it in a tool and the message goes back to the model with "Fix the errors and try again." appended (tools docs).final_result, plus tool_choice: "required": the model may never answer in plain text (output docs). Tools get strict: true and additionalProperties: false. A model that ends with a sentence instead of calling final_result gets a validation error back, and after one retry (the default) the run raises UnexpectedModelBehavior. That is what happened here, and the server explains why: mlx_lm.server 0.32.0 ignores tool_choice, so "required" never reached the model and nothing forced the call (read from its source and measured on Typed agent libraries).@agent.tool_plain(requires_approval=True)
def edit_file(...): ...
agent = Agent(..., output_type=[FixReport, DeferredToolRequests])
# the run ends with DeferredToolRequests; ask the human, then:
agent.run_sync(message_history=r.all_messages(),
deferred_tool_results=DeferredToolResults(approvals={call_id: True}))(deferred tools docs)ModelRetry, and retries= on the agent or tool (default 1). API failures: configure the HTTP client of the provider.Runner), turn limit, handoffs between agents, guardrails, sessions and tracing. By default a tool exception becomes an error message for the model.strict: true, additionalProperties: false and a title on every schema and argument: 491 tokens against our 397. It sent no max_tokens, so the server default decided the output cap.@function_tool(needs_approval=True) def edit_file(...): ... r = Runner.run_sync(agent, TASK) state = r.to_state() for item in r.interruptions: state.approve(item) # or reject r = Runner.run_sync(agent, state)(human-in-the-loop docs)
openai client's max_retries. Model mistakes: tool errors are returned as text by default.tools field at all), plus stop sequences. The code runs in the same process in LocalPythonExecutor, which its own docstring calls "not a security sandbox"; executor_type can be "docker", "e2b", "modal" or "blaxel" instead (secure execution docs). Past tool calls go back into the history as text, "Calling tools:\n" + str([...]) in memory.py (a Python repr, single quotes), with results as user messages starting "Observation:", not as native tool-call messages, even in its ToolCallingAgent.edit_file calls input()), or inspect each step with step_callbacks. Approval must live in the tool because one code step can call it many times.OpenAIServerModel retries rate-limit errors up to 3 attempts (RETRY_MAX_ATTEMPTS = 3). Model mistakes: errors in the code become the next observation.strict_mcp_config=True, the first run also loaded the subscription account's connected apps as tools: over a hundred thousand tokens of tool definitions on every call, for a task that needed four tools (that run is discarded). And without tools=[] plus our own system_prompt, the first call carries Claude Code's prompt and built-in tools (section 3).async def ask(name, args, ctx):
ok = input(f"{name} {args}? ") == "y"
return PermissionResultAllow() if ok else \
PermissionResultDeny(message="denied")
options = ClaudeAgentOptions(..., can_use_tool=ask)or a permission_mode, or a PreToolUse hook (permissions docs). Here allowed_tools pre-approved all four tools, so no prompt appeared.max_turns and max_budget_usd as stops. Model mistakes: tool errors return as tool results.output_type=FixReport, Pydantic AI accepts only a call to its final_result tool. The local model wrote "I modified the tokenize function ..." as text; the validation error went back as a retry prompt, and the run either exhausted its one output retry or wandered into more edits until the 15-request limit. The repository was fine; the contract between framework and model was not. A stronger model, or output_type=str, removes the failure.for f in list_files(): print(f). Our tool returns one newline-separated string (fine for a JSON tool call, where the model reads text), so Python iterated over its characters. With code actions, a tool's return type becomes part of its interface: return a list[str] to a code agent, text to a JSON-calling agent.strict_mcp_config, setting_sources, tools and system_prompt deliberately, or you inherit whatever the machine and account have configured.mlx-community/Qwen3-4B-Instruct-2507-4bit (model card, from Qwen3-4B-Instruct-2507) on mlx-lm 0.32.0 and mlx 0.32.3, Apple M1 Pro with 16 GB; temperature 0 (greedy) and 0.7, max 2,048 output tokens per call. Claude: claude-agent-sdk 0.2.163 with its bundled Claude Code 2.1.286 through a Claude subscription; haiku resolved to claude-haiku-4-5-20251001 and sonnet to claude-sonnet-5-5. Costs are not shown: the subscription paid, and the API-price equivalents Claude Code reports are not what anyone was billed. Recordings are redacted (paths replaced by /work, ids by labels, the init record reduced to model, permission mode, tools and version; thinking blocks kept only as a marker); Code, recordings and scripts: src/same/ in the repository. Claude Agent SDK docs: overview, Python reference. smolagents: what are agents.An agent framework is mostly a way of deciding who chooses the next step: your code or the model. This lab takes one small job, fixing the two bugs in the running example, and does it six ways, each recorded for real on . Then it kills a workflow halfway and brings it back, and finally splits the job across several agents.
"Systems where LLMs and tools are orchestrated through predefined code paths." Your code decides the order of steps; the model fills in each step. (Anthropic, Building effective agents, 19 Dec 2024)
"Systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks." The model decides the next step, every turn, until it stops. (same source)
The code (yours or a framework's) that decides which model call or tool runs next, passes outputs between them, and decides when the whole thing is finished.
textstats, with two planted bugs that its own test file catches: tokenize splits don't into don and t, and top_words does not break ties alphabetically. The task 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."
Passing the visible tests is a low bar, so every result is also run against six hidden checks derived only from the two docstrings ("Apostrophes inside words are kept", "ties broken alphabetically"). No model saw them. The unfixed code passes of them.
How the five workflows were run. The model is Claude Haiku 4.5 (claude-haiku-4-5-20251001) called through claude -p with every built-in tool switched off (--tools "") and its system prompt replaced, so it can only return text. A short Python script (in src/orch/code/) does everything else: reads the files, pastes them into prompts, parses the code the model returns, writes it, runs the tests. The free agent is the same model inside Claude Code (version ) with its own Read, Edit, Write, Bash, Grep and Glob tools, choosing every step itself. Same model everywhere, so the differences below come from the orchestration.
total_cost_usd); the runs were paid by a subscription.Pick a pattern. The graph shows its shape (blue boxes are model calls, grey boxes are plain code), the lanes underneath show when each step actually ran, to scale in seconds, and the counters add up tokens and cost as the replay moves. Choose a second pattern under "compare with" to run both on the same clock: that is the before/after, the same input through two designs.
The replay is a tool to drive: it opens on the end of the run, with every step drawn, and does not play by itself; press play to watch it on the recording's clock, or step through it, and read each step's caption under the lanes.
The instruction each call ended with (the pasted files and test output above it are left out) and the start of its reply. Full prompts and replies are in the redacted recordings in src/orch/recordings/.
* For the agent, model calls are distinct API messages in the stream; Claude Code itself reports this run as 11 turns. The agent also paid for tool definitions and its built-in system prompt on every call, which the workflow calls did not carry.
| Pattern | What it is (Anthropic, 2024) | Use it when (Anthropic) | In this lab |
|---|---|---|---|
| Prompt chaining | "Decomposes a task into a sequence of steps, where each LLM call processes the output of the previous one." | "the task can be easily and cleanly decomposed into fixed subtasks" | diagnose, a code gate, fix |
| Routing | "Classifies an input and directs it to a specialized followup task." | "distinct categories that are better handled separately" | each failing test to a parsing or a sorting specialist |
| Parallelisation | "LLMs can sometimes work simultaneously on a task and have their outputs aggregated programmatically." | "the divided subtasks can be parallelized for speed, or when multiple perspectives are needed" | sectioning: one call per failing test at once (the other form, voting, runs the same call several times) |
| Orchestrator-workers | "A central LLM dynamically breaks down tasks, delegates them to worker LLMs, and synthesizes results." | "complex tasks where you can't predict the subtasks needed" | the model writes the plan, workers fix one function each, the model checks the merge |
| Evaluator-optimizer | "One LLM call generates a response while another provides evaluation and feedback in a loop." | "clear evaluation criteria, and iterative refinement provides measurable value" | generate, run tests, strict reviewer, repeat (at most 3 rounds) |
| Agent | the model directs its own steps and tool use | open-ended problems where the number of steps cannot be predicted | Claude Code with tools, no plan given |
Quotes from Building effective agents (Erik Schluntz and Barry Zhang, Anthropic, 19 December 2024), checked 5 October 2026. The same post warns that frameworks "often create extra layers of abstraction that can obscure the underlying prompts and responses, making them harder to debug": each workflow here is 20 to 31 lines of plain Python (counted in src/orch/code/patterns.py), which is the point. The Same agent, six ways tab shows what the frameworks add on top.
The problem. A workflow lives in the memory of one process. If that process dies halfway (a deploy, an out-of-memory kill, a laptop lid), a plain script has lost everything: the model calls already paid for, the decisions already made. It starts again from zero and pays again. Long agent runs, and runs that wait hours for a human, make this the normal case rather than the rare one.
The idea. After every step, write the whole state of the run to a database. Each saved snapshot is a checkpoint; all the checkpoints of one run share a thread id. To recover, load the newest checkpoint of that thread and carry on from the step after it. The same mechanism gives two more features for free: pausing for a human (save, exit, and resume days later with the human's answer) and time travel (load an older checkpoint, optionally edit it, and run forward again on a new branch).
The recording. The prompt-chaining workflow above, rebuilt as a LangGraph StateGraph with five nodes and a SQLite checkpointer (langgraph , langgraph-checkpoint-sqlite ), run with durability="sync". A driver script started it, waited until the fix step's model call was in flight, and sent SIGKILL to the whole process group. Then it ran four more separate processes: resume, approve, rewind, approve. Every process is a fresh Python interpreter: the only thing that survives between them is the SQLite file.
The replay on the right opens on the end of the recording; play it or step through its 30 events (the caption under it names each one), and switch to "without one" for the same durations restarted from zero. The Reading tab's Fig. 3 walks the same recording in six explained stretches.
What bites in production, each measured on LangChain and LangGraph: when the checkpoint is written (the three durability modes, and that "exit" would have lost the diagnosis too, section 5); that a resumed node runs again from its first line, as the event log here shows with human_review starting twice, so a side effect before an interrupt must be idempotent (section 6); and that nothing restarts the process for you: something has to notice the crash and call invoke again with the same thread id (here, the driver script).
Each dot on the right is one row in the checkpoints table, read back with get_state_history. Click one to see what it holds:
Temporal is a workflow engine that predates LLM agents and is now often used to run them. It takes a different route to the same goal:
| LangGraph checkpointer | Temporal | |
|---|---|---|
| What is saved | a snapshot of the graph state after each step | an "Event History", "a complete, ordered log of everything that has already happened" |
| How it recovers | loads the newest snapshot and runs the next node | "starts the Workflow code from the beginning, replays the Event History step by step", reusing recorded results |
| Rule for your code | nodes should be idempotent (they may run twice) | workflow code must be deterministic: "make the same decisions when given the same history" |
| Where model calls go | inside nodes (or @task functions in the functional API) | in Activities, which handle "API calls, Database queries, LLM invocations, File I/O"; an Activity's result "is recorded in the Event History. During replay, that result is reused, not recomputed"; Activities get retry policies |
| Who restarts it | you, or the LangGraph platform | the Temporal service hands the workflow to another worker; workflows "can run, and keep running, for years, even if the underlying infrastructure fails" |
Temporal quotes from the Workflows page of the Temporal docs, checked 5 October 2026. Temporal was not run here. When you need durable, retried, long-running work across machines, the Temporal model is the stronger guarantee; when you need a graph with human pauses and rewinds inside one service, a checkpointer is usually enough.
The question. A multi-agent system splits a job across several model loops. The usual shape is orchestrator-workers with agents in place of single calls: a lead agent hands pieces of the job to subagents, each running its own loop in its own fresh context window, and reads back only their final reports. That separation is called context isolation: whatever a subagent reads (files, search results, dead ends) never enters the lead's context.
The recording. The free agent from above, against the same model told by an appended system prompt to run the tests, launch one subagent per failing test with Claude Code's subagent tool, wait for their reports, and apply the fixes itself.
The replay on the right opens on the end of the run; play it or step through the transcript (each line below marks where it is).
Top: when each agent was thinking (pale bars) and running tools (orange). Bottom: how many tokens each agent sent on its most recent model call, the size of its context, drawn to one scale in both runs.
Anthropic (13 June 2025, How we built our multi-agent research system) reports a lead with parallel subagents beating single-agent Claude Opus 4 by 90.2% on its internal research evaluation, at about 15 times the tokens of a chat, and says "most coding tasks involve fewer truly parallelizable tasks than research". Cognition (12 June 2025, Don't Build Multi-Agents) argues "Actions carry implicit decisions, and conflicting decisions carry bad results": two subagents building parts of a Flappy Bird clone each guess a different style, and the parts do not fit. Both posts, quoted in full and read against the other evidence: Multi-agent patterns, section 10. Where each applies to a task:
| Property of the task | Which argument wins | Why |
|---|---|---|
| Many independent, read-only lookups (research, search, audits) | Anthropic | pieces do not have to agree with each other; parallel contexts hold more material than one window; the extra tokens buy coverage |
| Pieces that write to the same artefact (code, a document, a design) | Cognition | each writer makes unstated choices; the merge is where they conflict |
| Read-only subagents that answer one question and report | both agree | no conflicting actions; the lead keeps every decision; this is the case Cognition carves out |
| A small task that fits in one context (this lab) | neither needs it | no window pressure and little to parallelise, so delegation is pure overhead: see the numbers above |
| A run longer than one context window | both offer an answer | Anthropic splits the work across windows; Cognition compresses history in one thread. Compare compaction on the Topic: agentic-harnesses page |
Both posts checked 5 October 2026. Both are vendor posts arguing from their own products; neither publishes its evaluation set. The 90.2% is Anthropic's internal measurement, not an independent one.
interrupt() inside a node with a checkpointer, then invoke(Command(resume=...)) on the same thread. Remember that the node re-runs from its start on resume.claude-haiku-4-5-20251001 for every call, on . Workflow calls: claude -p <prompt> --output-format stream-json --verbose --tools "" --system-prompt <role> --model haiku --no-session-persistence --setting-sources project --strict-mcp-config, run from an empty directory. Agent runs: the same flags with --tools "Read,Edit,Write,Bash,Grep,Glob" (plus the subagent tool for the multi-agent run), --permission-mode acceptEdits and --allowedTools "Bash(python3:*)" "Bash(python:*)", inside a fresh copy of the task repository.result record. The cost figure is list price: Claude Haiku 4.5 is $1 per million input tokens, $5 per million output tokens, cache reads $0.10, cache writes $1.25 (5-minute) or $2 (1-hour; the agent runs here wrote 1-hour entries) (Anthropic prompt caching docs, checked 5 October 2026). Check on the first chain call: . "Tokens processed" counts fresh input, cache writes and cache reads together.src/orch/redact.py): machine paths become /work, ids become short labels, thinking signatures and rate-limit events are dropped, and the em-dash characters the model wrote were replaced by ", ". The page's data file is generated from the redacted copies only (src/orch/build_data.py).python3 while the model typed python ( denied commands, it edited the code without ever running the tests), and a first multi-agent run in which the model ignored a softer instruction to delegate and solved the task alone.--- is parsed by the CLI as an option, a bug in the first version of the driver.The agent loop on your laptop calls one model with one key and prints what happened. A loop that serves real users needs three more things, and each one exists because something specific goes wrong without it: providers fail, so a gateway retries and falls back; nobody can see inside a run, so you record a trace; a prompt change quietly breaks things, so an eval gate checks every change. The last question is whether to run the loop at all, or rent one (a hosted runtime). This tab puts all of them around one running agent; each piece is taught on its own page (Gateways and routing, LLM observability), and memory across sessions on Context engineering, section 8.
A proxy between your code and the model providers. Your code speaks one API to it (usually OpenAI's chat format); it forwards each call to a provider and adds retries, fallbacks, timeouts, keys, budgets and a log of every call.
A span is one timed operation with a name and attributes (a model call, a tool call). A trace is the tree of spans for one request. OpenTelemetry (OTel) is the vendor-neutral standard for producing and shipping them.
A fixed set of tasks with automatic checks, run on every change to the agent (prompt, model, tools, harness version), with a gate that blocks the change if the checks get worse.
mlx-community/Qwen3-4B-Instruct-2507-4bit served by mlx-lm 0.32.0), a real OpenTelemetry Collector, and one real Claude Code run (Haiku 4.5) with its tracing switched on. The local model is a 4-billion-parameter model; never read its answers as a statement about Claude. The evals reuse the recorded Claude Code runs of the sibling root's Trace and context lab and this page's Orchestration lab.The problem. A model provider is a remote service, and remote services fail in three ordinary ways: they refuse you because you sent too much (HTTP 429 Too Many Requests, often with a Retry-After header saying how many seconds to wait), they break (500, 503), or they stop answering (a hang, which only a timeout ends). An agent makes ten or fifty calls per task, so a 1% failure rate per call becomes a failed task surprisingly often. Every provider also has its own SDK, keys, prices and limits.
How a gateway works. Your code sends every call to the gateway with a model name you chose (here primary). The gateway maps that name to one or more real deployments, sends the call, and when it fails decides what to do: wait and retry the same deployment, fall back to another model group, or give up. It also checks the caller's virtual key (a key the gateway issued, so the real provider keys never leave it), its budget and its rate limit, and logs the cost of every call. LiteLLM's proxy, OpenRouter and the cloud vendors' AI gateways all do some version of this.
retry_after, 0 by default)LiteLLM , read from its source: _calculate_retry_after in litellm/utils.py and the constants INITIAL_RETRY_DELAY = 0.5, MAX_RETRY_DELAY = 8.0, JITTER = 0.75 in litellm/constants.py. When other healthy deployments exist in the same group, the router retries at once instead (_time_to_sleep_before_retry in router.py).
Pick a failure. The fake provider is scripted to fail exactly that way; the request is sent once straight to it ("no gateway") and once through LiteLLM configured with 2 retries, an 8-second timeout on the primary, and a fallback from primary to backup (the local model). The lanes are to scale in seconds, and every bar is a recorded request.
The replay is a tool to drive: it opens on the end of the request, with every attempt drawn, and does not play by itself; play it or step through it, and the caption under the lanes names each event.
A virtual key is issued by the gateway and stored in its database (LiteLLM needs Postgres for this; it ran in Docker here). Each key can be limited to some model names, a spending cap in dollars and a number of requests per minute. The gateway prices every call with its own price table (here an illustrative $1 per million input tokens and $5 per million output tokens, set in the config because the local model has no price) and adds it to the key's spend.
OpenRouter is the same idea hosted: one OpenAI-compatible endpoint and one bill for models from many providers, with model fallbacks from a list, provider routing weighted by price, and fees on credit purchases; it was not run here, and its documented rules and its provider market are on Gateways and routing, section 9.
x-litellm-model-id header that names the deployment that answered, the tag the fallback warning above asks for.The recordings show one request at a time. Real traffic is many requests sharing one provider, and retries change that provider's load. The simulator below replays the same seeded trace of requests against a simulated provider that has a background error rate, occasional hangs, an outage window and a rate limit, first with no gateway and then through a gateway using LiteLLM's backoff formula. Both rows see exactly the same provider, so the difference is the policy.
The problem. An agent run is dozens of model calls and tool calls deciding each other. When it fails, costs too much or takes too long, the final answer does not tell you which step did it. Logging every call to a file helps until two runs interleave or a call is retried inside a gateway.
How tracing works, in one sentence: each operation opens a span (name, start, end, parent, attributes such as the model and token counts), the spans of one task share a trace id and form a tree, and an exporter ships them over OTLP to a collector or a backend; the OpenTelemetry GenAI conventions agree on the names (chat {model}, execute_tool {tool}, invoke_agent {agent}, gen_ai.usage.input_tokens), all still marked "Development". The conventions attribute by attribute, and why message content is opt-in: LLM observability, sections 1, 2 and 8.
Three real traces, all collected by an OpenTelemetry Collector (0.139.0, in Docker) writing OTLP JSON to a file. The first two are the same plain agent loop as the Same agent, six ways tab, run on the running example through the gateway above (its primary provider scripted to fail, so every model call fell back to the local model): once with spans written by hand following the conventions, once with only the official opentelemetry-instrumentation-openai-v2 package switched on. The third is Claude Code's own beta tracing on the same task.
Tracing turns a bill into a breakdown. Claude Code's llm_request spans carry four token counts each; priced at Haiku 4.5's list prices ($1 per million input tokens, $2 per million 1-hour cache-write tokens, $0.10 per million cache-read tokens, $5 per million output tokens; Claude Code writes its cache with the 1-hour TTL on these runs, see the shared facts of the Trace and context lab), they should add up to what the run reported.
Whether a backend gets the same total depends on names. LLM observability sent one Claude Code run to a self-hosted Langfuse: as-is, its spans (Claude Code's own token names) were priced at $0; renamed to the GenAI names, the cost came out 16% short of total_cost_usd, because the conventions have no field for 1-hour cache writes and Langfuse priced them as 5-minute writes; with Langfuse's explicit 1-hour cache key it matched exactly MEASURED. The same page instrumented one agent run eight ways: automatic instrumentation of the model client alone gave 8 separate flat traces, one per model call, with no tool spans, which is what the auto trace above shows too. Its sections 7 and 8 measure tail sampling and redaction on a real collector.
Where to send the spans (Langfuse, LangSmith, Braintrust, Arize Phoenix, all accepting OTLP) is compared by design on LLM observability, section 5, and Langfuse is run self-hosted there (section 4). Instrument with OpenTelemetry and keep the backend a configuration choice, as the collector here does. Tracing as a general engineering tool: Observability: logs, metrics, traces, alerting.
The problem. You change the system prompt, swap the model, add a tool or upgrade the harness. The demo still works. Did anything get worse? One run cannot tell you, because the same agent on the same task varies run to run in turns, cost and even in what it fixes.
How it works. Keep a fixed set of tasks. For each change, run the agent on them (several times each), keep the recordings, and score each recording with checks: deterministic code where possible (do the tests pass, were the tests edited, how much did it cost), a model judge only where code cannot decide. A gate compares the candidate with the baseline and blocks the change if it regresses. The suite below has no model in it: it scores recorded Claude Code runs of the running example from this page and the sibling root, rebuilding each run's final code from its recorded diff and rerunning the visible tests and the six hidden checks from the Orchestration lab (derived from the docstrings; no run saw them).
Everything above assumes you run the loop. Both large labs now sell the loop itself: you define an agent once, start sessions, send messages as events, and their servers run the model calls, the tools and a sandbox, keep the state, and stream events back. Neither was run here (both need an API key); this is from their documentation, read 5 October 2026.
| Claude Managed Agents | OpenAI Agents API | |
|---|---|---|
| What it is | "Pre-built, configurable agent harness that runs in managed infrastructure" (overview) | "gives your application access to the Codex harness through an OpenAI-managed API" (overview) |
| Status | Beta: every endpoint needs the managed-agents-2026-04-01 header; public beta since 8 April 2026 (release notes, per the shared facts file) | Beta (beta.agents endpoints); public beta since 10 September 2026 (OpenAI changelog, per the shared facts file) |
| Objects | Agent (model, system prompt, tools, MCP servers, skills), Environment (Anthropic cloud sandbox or self-hosted sandbox), Session, Events | Agent, Environment, Session, Events and items |
| Where tools run | "an Anthropic-managed cloud sandbox, or a self-hosted sandbox on your own infrastructure"; built-in Bash, file tools, web search and fetch, MCP | "OpenAI runs the agent and provisions and manages its sandbox", or a self-hosted environment |
| What it manages for you | "built-in prompt caching, compaction, and other performance optimizations"; history stored server-side; steer or interrupt mid-run | "OpenAI manages sessions, orchestration, context compaction, and recovery"; session state retained across turns |
| Price | Tokens at normal model prices plus $0.08 per session-hour of running time, metered to the millisecond; idle time is free; no Batch discount (pricing) | "Model usage is billed at the selected model's API rates"; "OpenAI-hosted sandboxes use standard container rates" |
| Data retention | Stateful, so "not currently eligible for Zero Data Retention" or HIPAA BAA coverage | Not checked here |
Anthropic's own worked example: one hour on Claude Opus 5, 50,000 input and 15,000 output tokens: $0.25 + $0.375 + $0.08 = $0.705; with 40,000 of the input tokens read from cache, $0.525. The runtime fee is small next to tokens for a busy agent; for a long, mostly-waiting session it is the part to watch.
disable_budget_reservation 20 simultaneous calls all got through at 4 times the budget (Gateways and routing).invoke_agent {agent name} span as the parent; a chat {model} span (kind CLIENT) per model call with gen_ai.operation.name, gen_ai.provider.name, gen_ai.request.model, gen_ai.usage.input_tokens and output_tokens, finish reasons; an execute_tool {tool name} span (kind INTERNAL) per tool call with gen_ai.tool.name and gen_ai.tool.call.id. Message content only as opt-in attributes. Auto-instrumentation of the model client gives you the chat spans only.mlx-community/Qwen3-4B-Instruct-2507-4bit at temperature 0. Claude Code 2.1.289 with Claude Haiku 4.5 for the one Claude run.src/ops/code/fake_upstream.py) follows a script per scenario (429 with Retry-After, 500, 503, a 20 s hang) and answers with fixed canned text when it succeeds; the backup is the local model behind a logging proxy. Config in src/ops/code/config.yaml, driver in gw_record.py. A first attempt lost its backup when the shared local model server ran out of GPU memory; the gateway then put the backup in cooldown and answered every request with "No deployments available ... Try again in 30 seconds" (HTTP 429). That run is kept in recordings/gateway_lesson.json as an example of a gateway turning a backend failure into rate-limit errors; the scenarios above were re-recorded afterwards.traced_loop.py is the Same agent tab's plain loop plus spans; each run used a fresh copy of the task repository. Claude Code ran with CLAUDE_CODE_ENABLE_TELEMETRY=1 CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 OTEL_TRACES_EXPORTER=otlp OTEL_LOGS_EXPORTER=otlp OTEL_LOG_TOOL_DETAILS=1, the six tools, --permission-mode acceptEdits and the same allow-list as the sibling root's Trace lab.src/ops/redact.py keeps raw files in the scratchpad and writes only whitelisted fields to src/ops/recordings/: no user, account, organisation, session or request ids, no paths outside the task copy, no key hashes; Claude Code's hook, plugin and settings events are dropped because they describe the account, not the run. em-dash characters in model output were replaced by ", ".src/ops/check_numbers.py recomputes the numbers quoted in the prose from the redacted recordings.Every external link checked on 6 October 2026 (HTTP 200); Notion pages by id. Times are estimates for a careful read.
One agent in a plain loop, LangGraph, Pydantic AI, the OpenAI Agents SDK, smolagents and the Claude Agent SDK, each run for real, with the requests they sent and how each adds approval and a retry. About 20 min, plus 12 closed.
The five workflow patterns and a free agent on one input, durable execution with a recorded kill, resume and fork, one agent against several. About 19 min, plus 4 closed.
A gateway with and without failures, traces and cost attribution, an eval gate on recorded runs, and hosted runtimes, around one running agent. About 21 min, plus 4 closed.
LangChain's Runnables, super-steps, checkpointers and what survives a crash, interrupts and Command, the store, create_agent, when a graph beats a plain loop. 35 min, plus 10 closed.
The Claude Code loop as a library: the pipe, options and their defaults, permissions, hooks, sessions, cost; tabs Options lab, Recordings. 30 min, plus 10 closed.
Pydantic AI, OpenAI Agents SDK, smolagents, Google ADK and Mastra by design axis: tool schemas, output modes, validate and retry, handoffs, guardrails, tracing. 28 min, plus 6 closed.
The taxonomy and the evidence: orchestrator-workers, blackboard, handoffs, two writers, debate and voting, each measured with its cost; MAST and the published studies read carefully. 32 min, plus 14 closed.
OpenTelemetry GenAI spans, eight instrumentations, Langfuse self-hosted, cost reconciled, sampling and redaction, evals on traces. 34 min, plus 9 closed.
LiteLLM from source: routing, retries, cooldowns, fallbacks, rate limits, budgets, caching; OpenRouter; routers and cascades; the tools compared. 37 min, plus 17 closed.
Memory across sessions (Mem0, Graphiti, Letta, measured on one twelve-session conversation) is on Context engineering, section 8, which absorbed the former child page Agent memory layers on 24 October 2026.
The sibling root: the agent loop, tools, context, permissions and sandboxes, the products, harnesses for training. Reading 24 min, plus 3 closed.
One LLM request on the wire; children MCP, Agent-to-agent and beyond (A2A) and Auth. About 42 min for the root.
How to grade agent runs: outcomes, trajectories, judges. About 30 min.
What agent scores measure and why the harness is part of the score. About 40 min.
The OS machinery under every agent sandbox. About 51 min.
inference-and-serving (what sits behind a gateway; 34 min), rag-and-retrieval (retrieval, next to memory; 21 min), ml-infra-and-orchestration (job systems and pipelines; 29 min).
Reasoning and acting interleaved: the loop every agent framework runs. About 21 min.
Many agents coordinating through a shared, re-executable record in Git instead of a planner. About 32 min.
Two recent designs for agent memory. About 27 and 20 min.
Anthropic, 19 Dec 2024. Workflows against agents and the five patterns; the reference for section 1. 25 min.
HumanLayer. Principles for agents you own: prompts, context, control flow, state. About 35 min for the twelve pages.
Anthropic and Cognition, June 2025: the two poles of the multi-agent debate; read together. 25 + 15 min.
Hamel Husain, 14 Feb 2024. Intercept what a framework sends before you trust it. 12 min.
Graphs, state, checkpointers, interrupts, time travel. Also the 1.0 release post (22 Oct 2025). About 45 min; post 12 min.
Schemas from signatures, ModelRetry, output validation. 20 min.
Agents, tools, handoffs, guardrails, sessions, tracing. About 40 min for the core pages.
Code as the action language, and the paper behind it (Wang et al., 2024). 20 min + 30 min.
Python, TypeScript, Go, Java and Kotlin; A2A; deployment on Google Cloud. About 30 min.
The design idea (give the agent a computer) and every option. 20 min + 40 min.
The role-based school and AutoGen's successor. 20 min each.
Durable execution by event-history replay, the alternative to checkpoints. 20 min.
Octomind, June 2024 (archived copy; the site is gone). The best-known critique of framework abstraction. 10 min.
Retries, fallbacks, cooldowns, timeouts. 15 min.
Pricing, routing, fees. 10 min.
The attribute names for model, agent and tool spans. 25 min.
The open-source tracing and eval platform's data model and self-hosting. About 40 min for the core pages.
The three memory designs Context engineering compares in its section 8, each in its authors' words (and benchmarks). About 30 min each.
The two hosted runtimes, from their own docs. 20 min.
Cemri et al., 2025: the MAST taxonomy of 14 failure modes. 40 min.
Kim et al., 2025 to 2026: 260 configurations, when coordination helps and hurts. 45 min.
2025: majority voting explains most of debate's gain. 30 min.
LangChain (16 Jun 2025) and Philipp Schmid (20 Jun 2025): the read and write framing. 15 + 10 min.
Two large 2026 runs: a shared graph of results, and what a green test suite missed. 20 min each.