In this article10 sections
Everyone calls everything an "agent". A script that searches a database and sends the result to a model becomes an agent. So does a loop that lets the model call tools. And now there are deep agents, with a to-do list, subagents and files, in the style of coding agents (Claude Code, Codex, Gemini CLI, Cursor).
The difference between them fits in one question: who decides the next step, and how much planning happens before acting? The rest follows from that: the cost, the time, and what you can audit afterwards.
To see it in numbers, we took one task and solved it four ways: fixed workflow, ReAct, plan-and-execute and deep agent. The tools, the document and the model were the same in all four. Everything was written by hand, with no framework, so the whole mechanism is visible. At the end, we show where each one appears in the ready-made frameworks.
The short version: ReAct, the simplest loop, scored as well as the other two agents on almost everything, at half the price or less. The deep agent only pulled ahead, narrowly, on a 20-question task with a small model, at 2.5 times the cost. The fixed workflow broke as soon as the task needed more than one search.
The code is at salada-dados/blog. The whole experiment cost about US$ 12.
The four types
Fixed workflow. The code decides the order: search once, take the pages found, send everything to the model, get the answer. The model only fills in the blank. It is the pipeline from part 3 of the RAG series. Strictly speaking it is not an agent, but it is the honest starting point: if it solves the problem, you don't need the others.
ReAct. The name comes from reasoning + acting, from a 2022 paper. The model thinks, picks a tool, sees the result and decides again, until it answers. Today, with native tool calling in the APIs, that is a while loop: call the model; if it asked for a tool, run it and call again; if it answered, stop. It was the agent in part 4.
Plan-and-execute. First the model writes a plan, without looking at anything. Then each step of the plan runs as a small ReAct loop, with its own context. At the end, a "replanner" reads what each step found and decides whether it can answer or whether steps are missing.
Deep agent. It is the pattern of coding agents, which LangChain packaged under this name. The main agent gets four things on top of the task's tools:
- a to-do list (
write_todos), which it writes and updates; - subagents (
task), each with its own context, which do one piece of research and return only a summary; - files (
write_file,read_file,ls) to keep notes outside the context; - a long prompt that teaches when to use each one.
The idea is to keep the main agent's context clean. Whole pages stay inside the subagents, and only the summary comes back.
The experiment
The tools are the ones from part 4: an MCP server over the Banco Central do Brasil's Monetary Policy Report of September 2026, with two functions. search_report(query) returns the 3 most similar chunks, each with its page. view_page(page) returns the page as an image, which is the only way to read the values in the charts.
The models, through OpenRouter: GPT-6.1 Sol, which got 65 of 66 questions right in part 4 at half the price of Claude Sonnet, and GPT-6 Luna, 20 times cheaper, to see whether the extra structure makes up for a weaker model.
Two test sets:
- The 33 short questions from the RAG series, in Portuguese and English: 66 in total, each with a single answer (a number, a name, a year).
- Four long tasks, also in both languages, each with a rubric of items:
- L1, the projections for 2026 and 2027 (11 items): GDP, credit, external accounts and inflation, from four different sections of the report.
- L2, what changed since the previous report (9 items): previous and current projections, taken from tables.
- L3, the labor market (8 items): partly in the text, partly only in the charts.
- L4, a 20-question briefing (20 items): 10 answers in tables and 10 only in charts, from across the report.
A long answer varies, even at temperature 0. So each task ran 3 times per language, and the tables show the mean of the 6 runs.
The grader for the long tasks is another model, from another provider (Claude Sonnet 5.5). It gets only the rubric and the answer, without knowing which agent wrote it, and marks item by item whether the answer has the right number, attached to the right thing. We checked several grades by hand. For the short questions, grading is the same as in the series: the answer must contain the right number or name.
Limits: ReAct had up to 6 steps on the short questions and 15 on the long tasks. Plan-and-execute had plans of up to 5 steps, each with up to 4 calls, and one round of replanning. The deep agent had up to 20 steps on the short questions and 25 on the long ones, and each subagent up to 6. On L4, all of them got more room, so none would lose for lack of steps.
Short questions: ReAct wins on everything
With GPT-6.1 Sol, 66 questions:
| Type | Right | Model calls per question | Tokens per question | Total cost | Time per question |
|---|---|---|---|---|---|
| Workflow | 49 | 1.0 | 7.3k | US$ 1.22 | 4 s |
| ReAct | 65 | 2.9 | 5.9k | US$ 0.71 | 8 s |
| Plan-and-execute | 64 | 5.0 | 7.2k | US$ 1.00 | 16 s |
| Deep agent | 65 | 5.2 | 16.7k | US$ 1.03 | 15 s |
Workflow and ReAct come from parts 3 and 4 of the series, with the same model.
Three things stand out.
The workflow gets fewer right and still costs more than ReAct. It always sends the 3 pages it found as images, even when one would do. ReAct opens only the page it needs, and often none.
Plan-and-execute and the deep agent take twice as long and get no more right. For a question like "how much did agriculture grow in the second quarter?", there is nothing to plan.
The deep agent goes through the ritual even when it doesn't need to. It wrote a notes file on 63 of the 66 questions, because the prompt tells it to save what it finds. But it used the to-do list only 3 times, and subagents another 3: the same prompt says a simple lookup can be done directly. The agent follows the prompt, not the size of the question.
Long tasks: the agents tie
With GPT-6.1 Sol, mean rubric items right over 6 runs:
| Type | L1 (11) | L2 (9) | L3 (8) | L4 (20) |
|---|---|---|---|---|
| Workflow | 4.0 | 3.8 | 5.0 | 2.5 |
| ReAct | 11 | 9 | 8 | 19.8 |
| Plan-and-execute | 11 | 9 | 8 | 19.5 |
| Deep agent | 11 | 9 | 8 | 19.8 |
And the price of each run:
| Type | L1 | L2 | L3 | L4 | Time on L4 |
|---|---|---|---|---|---|
| Workflow | US$ 0.010 | US$ 0.011 | US$ 0.010 | US$ 0.021 | 34 s |
| ReAct | US$ 0.035 | US$ 0.040 | US$ 0.026 | US$ 0.18 | 67 s |
| Plan-and-execute | US$ 0.087 | US$ 0.068 | US$ 0.060 | US$ 0.32 | 175 s |
| Deep agent | US$ 0.117 | US$ 0.098 | US$ 0.057 | US$ 0.29 | 143 s |
All three agents got everything, or almost everything, right on every task. The difference was in cost and time. The deep agent cost 1.6 to 3.3 times as much as ReAct, and plan-and-execute 1.7 to 2.5 times. Both took 2 to 4 times as long.
The workflow breaks on the first task with more than one part. A single search cannot reach four sections of the report. On L3, it got all 8 items in English and 2 in Portuguese: everything depended on the one search landing on the right pages. The three repeats gave exactly the same result. With no decision left to the model, there is nothing to vary.
We expected ReAct's context to overflow on L4. It didn't. The model asks for several tools in the same call, 3.6 on average, and solved the 20 questions in 7 to 10 calls, looking at 11 to 15 pages as images. That came to 223 thousand tokens per run, but three quarters of them were served from OpenAI's prompt cache, which charges much less for the part of the history that repeats. That is why the cost does not follow the tokens.
On the long tasks, the deep agent really used its tools. It wrote a to-do list and files in all 48 runs and called 1 to 5 subagents per run (4 or 5 on L4). It worked the way it was designed and reached the same result as ReAct, for more money.
With a weaker model, the structure starts to pay
The same tasks with GPT-6 Luna:
| Type | L1 (11) | L2 (9) | L3 (8) | L4 (20) | US$ per run on L4 | Time on L4 |
|---|---|---|---|---|---|---|
| Workflow | 4.0 | 4.0 | 4.8 | 2.5 | 0.001 | 11 s |
| ReAct | 11 | 9 | 7.5 | 19.2 | 0.015 | 66 s |
| Plan-and-execute | 11 | 8.3 | 7.7 | 18.5 | 0.023 | 175 s |
| Deep agent | 11 | 9 | 7.8 | 19.7 | 0.038 | 224 s |
The deep agent finally won something. On L4, it got all 20 items in 4 of the 6 runs. ReAct got all 20 in one. The edge is half an item, for 2.5 times the cost and 3.4 times the time. With the weaker model, ReAct looked at fewer pages (7 to 10, against 11 to 15 with Sol) and missed more chart items. The subagents, each focused on a few questions, made up for part of that.
Plan-and-execute got worse. It fell below ReAct on L2 and L4. On L2, in 4 of the 6 runs, the step in charge of earmarked credit found in the text that the projection "was revised upward by 1.0 p.p. in both segments" and stopped there, without opening the table on the next page, which has both values. The replanner read "could not find the exact aggregate rates" and answered anyway. Each step sees only its own piece, and nobody goes back to check.
And the most useful lesson for your budget: Luna did almost the same as Sol for between an eighth and a twentieth of the price. One L4 run with ReAct cost US$ 0.18 on Sol and US$ 0.015 on Luna. Changing the model moved the cost far more than changing the architecture.
What your coding assistant will not warn you about
Ask a coding assistant for "an agent that researches the report" and you will almost always get a framework installed and code that works on the first question. These are the points that usually get left out.
It reaches for the framework, sometimes the old version
The first reflex is to install something and call a ready-made constructor. The most common ones in tutorials have already changed. LangGraph's create_react_agent was deprecated in favor of create_agent in LangChain 1.0. Microsoft's Semantic Kernel and AutoGen were replaced by the Microsoft Agent Framework, which reached version 1.0 in April 2026. An assistant trained before that will suggest the old API with full confidence.
And the whole ReAct loop fits in about 20 lines, as shown below. Before adopting a framework, it is worth knowing what it does underneath.
It picks the architecture by fashion, not by the task
A request for a "robust agent" turns into a deep agent, with subagents and files, to answer one-line questions. On our 66 short questions, that cost 45% more and took twice as long, with not one extra right answer. Start with the simplest thing that works and move up only when you measure that it fails.
It does not cap steps or spending
Every agent loop needs a step limit and, on the last step, an instruction to answer with what it has. Without that, a hard task becomes an expensive loop. We used limits per agent type and a dollar budget that stops the whole run. And it was the OpenRouter credit that ran out first: four runs failed with a 402 error. The disk cache kept every finished run, so resuming cost only what was left.
It counts tokens and calls it cost
The deep agent used 2.8 times as many tokens as ReAct on the short questions. It cost 1.45 times as much. The difference comes from the prompt cache: in a loop, the history repeats on every call, and the repeated part is cheaper. On the long tasks, where we started recording it, between 37% and 77% of the input tokens came from the cache, depending on the agent. To compare architectures, use the cost the API reports, not the token count.
It writes a grader that fails silently
Our first grader read the judge's reply as JSON and, if parsing failed, marked every item wrong. In one run, the judge returned something that was not JSON, and a correct answer scored 0 out of 20. Plan-and-execute's mean on L4 dropped from 18.5 to 15.5. We nearly flipped the conclusion. Now the grader asks again and, if it cannot get a grade, records nothing. It is the kind of except a coding assistant writes without a second thought: the code doesn't break, and the number comes out wrong.
The solution, in code
The ReAct loop, which also runs inside each plan-and-execute step and each deep agent subagent:
async def loop(run, agent, messages, specs, execute, max_steps, lang):
for step in range(max_steps + 1):
last = step == max_steps
if last: # on the last step, no tools: answer with what you have
messages.append({"role": "user", "content": LAST_STEP[lang]})
msg = await chat(run, messages, None if last else specs)
tool_calls = msg.get("tool_calls") or []
if not tool_calls:
return msg.get("content") or ""
messages.append({"role": "assistant", "content": msg.get("content") or "", "tool_calls": tool_calls})
images = []
for tc in tool_calls:
text, pics = await execute(tc["function"]["name"], parse_args(tc))
messages.append({"role": "tool", "tool_call_id": tc["id"], "content": text})
images += pics
if images: # a tool message carries only text: the image goes right after it
messages.append({"role": "user", "content": [{"type": "text", "text": "Requested page images:"}] + images})
return ""The deep agent is the same loop with five more tools. The one that makes the difference is task, which opens a subagent with a clean context and returns only its final text:
if name == "task":
state["subagents"] += 1
messages = [{"role": "system", "content": SUBAGENT[lang]},
{"role": "user", "content": args.get("description") or ""}]
return await loop(run, "subagent", messages, tools.specs, sub_execute, sub_steps, lang), []The pages a subagent opens stay in its own history, which is thrown away at the end. That is how the deep agent saves context. It is also why it needs more calls: every subagent starts from zero.
When to use each one:
| Type | Use it when | Avoid it when |
|---|---|---|
| Workflow | The steps are always the same and one search is enough. Tight response times, predictable cost | The task has several parts, or the search may miss the page |
| ReAct | It is the default. Tools, short questions or tasks of up to dozens of lookups | The history no longer fits in the context, even with the cache |
| Plan-and-execute | Someone needs to see or approve the plan first, or the steps can run in parallel | You want more right answers: here, it never beat ReAct |
| Deep agent | Large tasks, with many pages or documents, or a cheap model that gets lost in a long history | Simple questions: it goes through the whole ritual, and charges for it |
The ready-made version
We did everything by hand to show the mechanism. In production, these are the most used options, and where each type shows up:
- LangChain (
create_agent): ReAct ready to use, with middleware for step limits, history summarization and human approval. It replaced LangGraph'screate_react_agent. - LangGraph: for building the flow as a graph. Works for workflows, plan-and-execute and combinations of the two.
- deepagents (LangChain): the deep agent ready to use, with
create_deep_agent. It comes withwrite_todos, file tools (ls,read_file,write_file,edit_fileand others) and subagents through thetasktool. It runs on LangGraph. - Claude Agent SDK (Anthropic): the same engine as Claude Code, with subagents, files and a to-do list. A ready-made deep agent, built for Claude models.
- OpenAI Agents SDK: agents, tools, passing work between agents (handoffs) and input and output checks (guardrails). Lightweight, closer to ReAct.
- Microsoft Agent Framework: the successor to Semantic Kernel and AutoGen, in Python and .NET. If you have a Semantic Kernel project, Microsoft's documentation has migration guides.
- Google ADK: Google's agent kit, with sequential, parallel and loop agents.
- CrewAI: several agents with roles ("researcher", "reviewer") working together.
- smolagents (Hugging Face): minimalist. The agent writes Python code as its action, instead of calling one tool at a time.
What holds for all of them: the framework picks limits, prompts and history format for you. Read those defaults before comparing results, or you will be comparing configurations, not architectures.
Caveats before generalising
One document, one model provider. A 90-page report and two OpenAI models. With another document, or with models that don't ask for several tools at once, ReAct may do worse on long tasks.
The tasks are still small for a deep agent. The largest needed about 20 lookups. Deep agents were designed for hours of work, with hundreds of steps, where a ReAct history cannot fit at all. That scenario was not tested here.
Our deep agent is a simplified version. It has no file editing, no search across files and no automatic history summarization, which the frameworks include. With those pieces, the result could change, for better or worse.
The judge varies too. Grading the same answer twice, it changed the score by up to one item. Differences of half an item between agents are close to that noise.
Models and prices change. The numbers are from November 2026.
What's next
This is the first article in the Agents in Practice series. Now that architectures can be compared on cost and accuracy, the next tests can go where ReAct should really struggle: tasks with hundreds of steps, several documents, and tools that write, not just read.
