Skip to content

Building effective agents

Skip →CodeAct: code as the action space
main track #3corefundamentalblogrubric 10/122024 · Anthropic Engineering blog · ~25 min

Erik S., Barry Zhang

Status

TL;DR. The essay splits “agentic systems” into workflows, where LLM calls and tools follow code paths you wrote, and agents, where the LLM directs its own process and tool use. It starts from one building block (an LLM augmented with retrieval, tools and memory), describes five workflow patterns (prompt chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer), and then the agent: an LLM using tools in a loop on feedback from the environment. The advice throughout is to use the simplest design that works and to invest as much in the agent-computer interface (tools and their documentation) as you would in a user interface.

Why it matters now. This is the shared vocabulary of the agent field. Search-R1, WebThinker and deep-research systems are all “agents” in this sense, while many RAG pipelines are workflows. For an IR researcher, the useful question it raises is who chooses the next retrieval step: code you wrote, or the model. That choice decides what you can evaluate, what you can train with RL, and how much each answer costs. Note the date: the essay was published in December 2024, and the page now opens with a note that much of its tooling advice has changed and points to the 2026 Managed Agents essay. The patterns are still the standard taxonomy; the framework and SDK advice is dated.

Building effective agents: six workflow patterns and the agent loop, ordered by who chooses the next step Top two rows: workflows, where LLM calls and tools follow predefined code paths. The augmented LLM (one call with retrieval, tools and memory) is the building block. Prompt chaining runs fixed steps with programmatic gates. Routing classifies the input and sends it to a specialised prompt or model. Parallelization either splits independent subtasks (sectioning) or runs the same task several times (voting). Orchestrator-workers lets a central LLM choose subtasks at run time and synthesise the workers' results. Evaluator-optimizer loops between a generator and a critic until criteria are met. Bottom row: an agent, where the LLM uses tools in a loop on environment feedback and stops when the task is done, at a human checkpoint, or at a maximum number of iterations. An arrow at the bottom runs from control flow fixed in code to control flow chosen by the model, with flexibility, cost, latency and compounding errors all growing to the right. From one augmented call to an agent: who chooses the next step? WORKFLOWS: LLM calls and tools follow predefined code paths Augmented LLM retrieval + tools + memory one call: the base unit Prompt chaining fixed steps in sequence code gates check outputs Routing classify, then send to a specialised prompt/model Parallelization sectioning: split subtasks voting: same task k times Orchestrator–workers LLM picks subtasks at run time, then synthesises Evaluator–optimizer generate, critique, revise loop until criteria met AGENT: the LLM directs its own process and tool use Agent loop think → call a tool → read the result from the environment (ground truth) → repeat stop when the task is done, at a human checkpoint, or at a maximum number of iterations control flow fixed in code control flow chosen by the model to the right: more flexibility, but more cost, latency and compounding errors
Original sketch. The five workflow patterns and the agent loop, ordered by how much control flow is handed to the model.

Problem. Given a task, how much control flow should you hand to the model? More autonomy handles open-ended tasks, but costs more, adds latency and lets errors compound. The essay’s answer is a ladder you climb only when evaluation shows the next step pays off.

The building block. An augmented LLM is one model call that can generate its own search queries, choose tools and decide what to remember. The essay suggests the Model Context Protocol (MCP) as one way to connect tools. For many applications, it says, one well-optimised call with retrieval and in-context examples is enough.

Five workflows (code decides the path):

  1. Prompt chaining. Fixed steps, each consuming the previous output, with optional programmatic gates that check intermediate results. It trades latency for accuracy by making each call easier.
  2. Routing. Classify the input, then send it to a specialised prompt or model. The current version of the page gives the example of sending easy questions to a small model (Haiku 4.5) and hard ones to a larger model (Sonnet 4.5).
  3. Parallelization. Sectioning splits a task into independent subtasks (for example, one call answers while another screens for inappropriate requests). Voting runs the same task several times for more confidence.
  4. Orchestrator-workers. A central LLM breaks the task down at run time, delegates the pieces and synthesises the results. It looks like sectioning, but the subtasks are not predefined.
  5. Evaluator-optimizer. One call generates, another critiques, and the loop repeats. The essay gives two signs of a good fit: a human’s feedback demonstrably improves the output, and the LLM can give that kind of feedback itself. One listed example is search that needs several rounds, where the evaluator decides whether more searches are warranted.

Agents (the model decides the path). An agent plans and acts on its own after the task is clear. It must get ground truth from the environment at each step (tool results, code execution), may pause for a human at checkpoints, and usually has a stopping condition such as a maximum number of iterations. Use agents when you cannot predict the number of steps or hard-code the path, and only in environments you trust, because autonomy means higher cost and compounding errors.

Worked arithmetic: why gates and votes help (illustrative, not from the essay). Suppose each step of a 5-step chain is correct with probability p=0.9p = 0.9 and any error ruins the answer. End-to-end accuracy is p5≈0.59p^5 \approx 0.59. A gate that catches a wrong step with probability g=0.8g = 0.8 and allows one retry raises per-step success to

p′=p+(1−p) g p=0.9+0.1×0.8×0.9=0.972,p′5≈0.87,p' = p + (1-p)\,g\,p = 0.9 + 0.1 \times 0.8 \times 0.9 = 0.972, \qquad p'^5 \approx 0.87,

at an expected 1+(1−p)g=1.081 + (1-p)g = 1.08 calls per step. Voting over three independent samples of a step with accuracy 0.70.7 gives 0.73+3(0.72)(0.3)=0.7840.7^3 + 3(0.7^2)(0.3) = 0.784. Real samples from one model often share failure modes, which can reduce the gain, so check the independence assumption against measured joint outcomes. This is the same reason rank fusion works best with diverse rankers.

Three principles. Keep the design simple; make the agent’s planning steps visible; and design the agent-computer interface (ACI) carefully through tool documentation and testing.

Tool formats (Appendix 2). Some formats are much harder for a model to write than others, even when they are equivalent for software. A diff needs the line count in the chunk header before the new code is written; code inside JSON needs extra escaping. The suggestions: give the model tokens to think before it commits, keep formats close to text found on the internet, and remove overhead such as counting lines. Poka-yoke the tools: change arguments so mistakes are harder to make.

Before (single call or hand-built pipeline)This essay’s framing
Unit of designOne prompt, or a fixed pipelineA ladder: augmented call → five workflows → agent
Who picks the next stepYour codeYour code (workflows) or the model (orchestrator, agent)
ToolsAfterthoughtThe ACI deserves as much effort as a UI
What did not changeThe model and the need to evaluate every added step
EvidencePractitioner experience with customers and internal builds; no controlled comparison is reported

This is an engineering essay, so it reports experience rather than measured results. The concrete claims are:

  • SWE-bench agent (vendor-reported, internal build). The team “spent more time optimizing our tools than the overall prompt”. The model made mistakes with relative file paths after moving out of the root directory; changing the tool to require absolute paths fixed this, and the essay says the model then used it flawlessly.
  • Where agents work in practice (Appendix 1). Customer support and coding agents, chosen because they combine conversation with action, have clear success criteria, allow feedback loops and keep humans in the loop. For coding, automated tests verify solutions, but the essay notes that human review is still needed.
  • No measurements. The patterns and the “start simple” advice come from practice. Whether a workflow beats an agent at equal cost on a given task is an empirical question each team has to answer with its own evals.
  • Dated tooling. The framework list and SDK advice are from late 2024, and the page’s own banner says the landscape has changed. Read the patterns as a taxonomy and the tooling as history.
  • Autonomy is not binary. Real systems mix patterns, for example a router in front of an agent or an agent whose sub-agents are fixed workflows. The essay says the patterns are meant to be combined but gives no guidance on choosing combinations.
  • Open question for RL. Search agents trained with RL learn the control flow that this essay hand-designs. Does training remove the need for hand-built workflows, or do trained agents still benefit from gates, routers and verifiers around them?

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    A five-step prompt chain has per-step accuracy 0.9, and errors anywhere make the final answer wrong. You add a programmatic gate after every step that catches a wrong output with probability 0.8 and triggers one retry (the retry is again correct with probability 0.9 and is not re-checked). Compute end-to-end accuracy with and without gates, and the expected number of LLM calls per run. Then compute majority-of-3 voting accuracy for a single step with accuracy 0.7, and identify the assumption behind the voting figure and why measured joint outcomes are needed before trusting it.

    What a strong answer covers
    • Without gates: 0.9 to the 5th power ≈ 0.59.
    • With gates, per-step success is 0.9 + 0.1 × 0.8 × 0.9 = 0.972, so five steps give 0.972 to the 5th ≈ 0.87.
    • Expected calls per step are 1 + 0.1 × 0.8 = 1.08, so about 5.4 calls per run instead of 5 (ignoring gate false alarms, which would add more).
    • Majority of 3 with independent errors: 0.7³ + 3 × 0.7² × 0.3 = 0.343 + 0.441 = 0.784.
    • The 0.784 assumes the three samples err independently. Samples from the same model and prompt often share failure modes, which can reduce the gain; varied prompts or models reduce that correlation.
    • Dependence does not fix the direction in general: the same 0.7 marginal accuracy is compatible with majority accuracy below or above 0.784, so measure how often the samples are jointly right on real inputs.
  2. Mechanism

    Orchestrator-workers and parallelization-by-sectioning can draw the same diagram: one call fans out to several workers and the results are merged. Explain what actually differs in where the decomposition comes from, what failure modes each one has, and why the essay places orchestrator-workers closer to an agent than sectioning is.

    What a strong answer covers
    • Sectioning uses subtasks fixed in code ahead of time (for example, one call answers while another screens for policy violations).
    • In orchestrator-workers, a central LLM decides the subtasks at run time from the specific input (for example, which files to change), then synthesises the workers' outputs.
    • Sectioning fails when the fixed split does not fit an input; orchestrator-workers can produce a bad, overlapping or incomplete decomposition and must merge outputs it did not plan in advance.
    • Choosing the decomposition is a piece of control flow handed to the model, which is the essay's defining property of agents, so it sits further along the workflow-to-agent axis.
  3. Critique

    The essay's central advice is to start with the simplest solution and add agentic complexity only when it demonstrably improves outcomes. Critique the evidence behind this advice as presented in the essay, and design a fair experiment that tests it for a deep-research question-answering product.

    What a strong answer covers
    • The essay is based on customer and internal experience, with no controlled comparison reported; it is practitioner guidance, not a measured result.
    • A fair test fixes the model and gives each design (single call with retrieval, a fixed chain, orchestrator-workers, a full agent) the same task set and reports accuracy against cost and latency, not accuracy alone.
    • Compare designs at matched token or dollar budgets, because more calls alone can explain gains.
    • Stratify by task difficulty: simple lookups may favour a single call while multi-hop questions favour an agent, so an average can hide the crossover.
    • Report variance over repeated runs, since agents are less predictable than fixed workflows.
  4. What if…

    The essay says that for its SWE-bench agent the team spent more time optimising tools than the overall prompt, and that requiring absolute file paths removed a class of errors. Design an ablation that separates the contribution of tool design (the agent-computer interface) from prompt design, and say which measurements would show where the gain comes from.

    What a strong answer covers
    • Hold the model and task set fixed and cross two factors: original versus revised tool definitions, and original versus revised system prompt (a 2×2 design).
    • Measure resolve rate, plus tool-call error counts by type (for example, path-not-found errors) and the number of steps per task.
    • If the absolute-path change works as described, path-related errors should drop sharply under revised tools regardless of the prompt.
    • Repeat with several seeds or runs per task, since single-run differences on a few hundred tasks can be noise.
    • Check the interaction term: a prompt fix that only compensates for a bad tool should matter less once the tool is fixed.
  5. Connect

    Map each of the five workflow patterns onto a classic IR technique or system design that an IR researcher already knows, and for each say what the LLM version changes and what problem from the IR version it inherits.

    What a strong answer covers
    • Routing resembles query classification or federated search (vertical selection); it inherits misrouting errors that the downstream step cannot repair.
    • Parallelization by voting resembles rank fusion or ensembles; it inherits the need for diverse, not just repeated, components.
    • Prompt chaining with gates resembles a multi-stage pipeline (retrieve, rerank, read); it inherits error propagation between stages.
    • Orchestrator-workers resembles query decomposition for multi-hop QA; it inherits bad sub-question generation.
    • Evaluator-optimizer resembles relevance feedback or iterative query refinement; it inherits the risk that the feedback signal is itself wrong.
  6. Design

    You are building a system that answers BrowseComp-Plus questions over its fixed corpus with a BM25 or dense retriever as the only tool. Choose a design from the essay's ladder (single augmented call, fixed chain, orchestrator-workers, or agent), justify it using the essay's criteria for when each pattern fits, and say what stopping condition and transparency features you would add.

    What a strong answer covers
    • BrowseComp-Plus questions need an unknown number of searches with constraints checked one by one, so the number of steps cannot be fixed in advance, which is the essay's criterion for an agent.
    • The agent gets ground truth from the environment at each step: search results and fetched documents show whether a constraint is satisfied.
    • Stopping conditions: answer when all constraints are verified, plus a hard cap on search calls or tokens to bound cost.
    • Transparency: log the plan, every query and the document ids used as evidence, so failures can be attributed to retrieval or to reasoning.
    • A routing step can still send easy questions to a cheap single-call baseline, combining a workflow with an agent.

Done with this page?

Status