Common Agentic Patterns

The Top Patterns from Anthropic's Case Studies

In partnership with

Find out why 1M+ professionals read Superhuman AI daily.

In 2 years you will be working for AI

Or an AI will be working for you

Here's how you can future-proof yourself:

  1. Join the Superhuman AI newsletter – read by 1M+ people at top companies

  2. Master AI tools, tutorials, and news in just 3 minutes a day

  3. Become 10X more productive using AI

Join 1,000,000+ pros at companies like Google, Meta, and Amazon that are using AI to get ahead.

Hello everyone and welcome to my newsletter where I discuss real-world skills needed for the top data jobs. 👏

This week I’m discussing common agentic patterns seen in the real-world.  👀

The actual number is 250K last month and since February of 2107 I’ve amassed 73.6 millions views across multiple platforms. I’m not trying to flex here but that puts me in the top 1% of all authors in the world of artificial intelligence. Join the enlightened. 🤓

 Not a subscriber? Join the informed. Over 200K people read my content monthly.

 Thank you. 🎉

I’ve been completely blown away by the progress of artificially intelligent agents. All the research for this article is based on Anthropic.

Anthropic is a San Francisco-based artificial intelligence (AI) research company founded in 2021 by former OpenAI executives, including siblings Dario and Daniela Amodei.

Anthropic is best known for its Claude family of large language models (LLMs), which serve as advanced AI assistants.These models are designed to perform a variety of tasks, such as coding assistance, content creation, and complex problem-solving.

Let’s start learning about agents and common agentic patterns. 

What are agents?

Agent can be defined in several ways. Some define agents as fully autonomous systems that operate independently over extended periods, using various tools to accomplish complex tasks. Others use the term to describe more prescriptive implementations that follow predefined workflows. All the research about this article came from Anthropic, so we are going to use their nomenclature whenever possible.

Here is how Anthropic categorize all these variations as agentic systems, but draw an important architectural distinction between workflows and agents. This is actually how everyone defines them. 😁 

  • Workflows - are systems where LLMs and tools are orchestrated through predefined code paths. (Linear)

  • Agents - on the other hand, are systems where LLMs dynamically direct their own processes and tool usage, maintaining control over how they accomplish tasks.(Dynamic)

Let’s explore common agentic design patterns these seen from their customer base. I’ll put the type of agentic system in front of the pattern. For example, the second pattern will be WORKFLOW: PROMPT CHAINING. That means prompt chaining is a linear workflow approach.

Learn AI in 5 minutes a day

What’s the secret to staying ahead of the curve in the world of AI? Information. Luckily, you can join 1,000,000+ early adopters reading The Rundown AI — the free newsletter that makes you smarter on AI with just a 5-minute read per day.

FOUNDATION: THE AUGMENTED LLM

The basic building block of agentic systems is an LLM enhanced with augmentations such as retrieval, tools, and memory. Our current models can actively use these capabilities—generating their own search queries, selecting appropriate tools, and determining what information to retain. Here’s a diagram of this approach.

Augmented LLM

Anthropic recommends focusing on two key aspects of the implementation:

  • Tailoring these capabilities to your specific use case.

  • Ensuring they provide an easy, well-documented interface for your LLM.

While there are many ways to implement these augmentations, one approach is through our recently released Model Context Protocol, which allows developers to integrate with a growing ecosystem of third-party tools with a simple client implementation.

WORKFLOW: PROMPT CHAINING

Prompt chaining decomposes a task into a sequence of steps, where each LLM call processes the output of the previous one. You can add programmatic checks, gate in the diagram below, on any intermediate steps to ensure that the process is still on track.

Prompt Chaining Workflow

This workflow is ideal for situations where the task can be easily and cleanly decomposed into fixed subtasks. The main goal is to trade off latency for higher accuracy, by making each LLM call an easier task.

Examples where prompt chaining is useful:

  • Generating Marketing copy, then translating it into a different language.

  • Writing an outline of a document, checking that the outline meets certain criteria, then writing the document based on the outline.

WORKFLOW: ROUTING

Routing classifies an input and directs it to a specialized followup task. This workflow allows for separation of concerns, and building more specialized prompts. Without this workflow, optimizing for one kind of input can hurt performance on other inputs.

Routing Workflow

When to use this workflow: Routing works well for complex tasks where there are distinct categories that are better handled separately, and where classification can be handled accurately, either by an LLM or a more traditional classification model/algorithm.

Examples where routing is useful:

Directing different types of customer service queries (general questions, refund requests, technical support) into different downstream processes, prompts, and tools.

Routing easy or common questions to smaller models like Claude 3.5 Haiku and hard/unusual questions to more capable models like Claude 3.5 Sonnet to optimize cost and speed.

WORKFLOW: PARALLELIZATION

LLMs can sometimes work simultaneously on a task and have their outputs aggregated programmatically. This workflow, parallelization, manifests in two key variations:

  • Sectioning: Breaking a task into independent subtasks run in parallel.

  • Voting: Running the same task multiple times to get diverse outputs.

Workflow Parallelization

When to use this workflow: Parallelization is effective when the divided subtasks can be parallelized for speed, or when multiple perspectives or attempts are needed for higher confidence results. For complex tasks with multiple considerations, LLMs generally perform better when each consideration is handled by a separate LLM call, allowing focused attention on each specific aspect.

Examples where parallelization is useful:

  • Sectioning:

    • Implementing guardrails where one model instance processes user queries while another screens them for inappropriate content or requests. This tends to perform better than having the same LLM call handle both guardrails and the core response.

    • Automating evals for evaluating LLM performance, where each LLM call evaluates a different aspect of the model’s performance on a given prompt.

  • Voting:

    • Reviewing a piece of code for vulnerabilities, where several different prompts review and flag the code if they find a problem.

    • Evaluating whether a given piece of content is inappropriate, with multiple prompts evaluating different aspects or requiring different vote thresholds to balance false positives and negatives.

WORKFLOW: ORCHESTRATOR-WORKERS

In the orchestrator-workers workflow, a central LLM dynamically breaks down tasks, delegates them to worker LLMs, and synthesizes their results.

Orchestrator-Workers Workflow

When to use this workflow: This workflow is well-suited for complex tasks where you can’t predict the subtasks needed (in coding, for example, the number of files that need to be changed and the nature of the change in each file likely depend on the task). Whereas it’s topographically similar, the key difference from parallelization is its flexibility—subtasks aren't pre-defined, but determined by the orchestrator based on the specific input.

Example where orchestrator-workers is useful:

  • Coding products that make complex changes to multiple files each time.

  • Search tasks that involve gathering and analyzing information from multiple sources for possible relevant information.

WORKFLOW: EVALUATOR OPTIMIZER

In the evaluator-optimizer workflow, one LLM call generates a response while another provides evaluation and feedback in a loop.

Evaluator Optimizer

When to use this workflow: This workflow is particularly effective when we have clear evaluation criteria, and when iterative refinement provides measurable value. The two signs of good fit are, first, that LLM responses can be demonstrably improved when a human articulates their feedback; and second, that the LLM can provide such feedback. This is analogous to the iterative writing process a human writer might go through when producing a polished document.

Examples where evaluator-optimizer is useful:

  • Literary translation where there are nuances that the translator LLM might not capture initially, but where an evaluator LLM can provide useful critiques.

  • Complex search tasks that require multiple rounds of searching and analysis to gather comprehensive information, where the evaluator decides whether further searches are warranted.

AGENTS

Agents are emerging in production as LLMs mature in key capabilities—understanding complex inputs, engaging in reasoning and planning, using tools reliably, and recovering from errors. Agents begin their work with either a command from, or interactive discussion with, the human user. Once the task is clear, agents plan and operate independently, potentially returning to the human for further information or judgement.

During execution, it's crucial for the agents to gain ground truth from the environment at each step (such as tool call results or code execution) to assess its progress. Agents can then pause for human feedback at checkpoints or when encountering blockers. The task often terminates upon completion, but it’s also common to include stopping conditions (such as a maximum number of iterations) to maintain control.

Agents can handle sophisticated tasks, but their implementation is often straightforward. They are typically just LLMs using tools based on environmental feedback in a loop. It is therefore crucial to design toolsets and their documentation clearly and thoughtfully.

When to use agents: Agents can be used for open-ended problems where it’s difficult or impossible to predict the required number of steps, and where you can’t hardcode a fixed path. The LLM will potentially operate for many turns, and you must have some level of trust in its decision-making. Agents' autonomy makes them ideal for scaling tasks in trusted environments.

The autonomous nature of agents means higher costs, and the potential for compounding errors. We recommend extensive testing in sandboxed environments, along with the appropriate guardrails.

The following examples are from Anthropic’s own implementations:

  • A coding Agent to resolve SWE-bench tasks, which involve edits to many files based on a task description;

  • Our computer use reference implementation, where Claude uses a computer to accomplish tasks.

These building blocks aren't prescriptive. They're common patterns that developers can shape and combine to fit different use cases. The key to success, as with any LLM features, is measuring performance and iterating on implementations. To repeat: you should consider adding complexity only when it demonstrably improves outcomes.

Success in the LLM space isn't about building the most sophisticated system. It's about building the right system for your needs. Start with simple prompts, optimize them with comprehensive evaluation, and add multi-step agentic systems only when simpler solutions fall short.

Thanks and have a great day. 👏

There is only one entry level data role and it’s the data analyst.

I’ve created the courses, study guides and a GPT for preparing for this role. All you need to do is follow directions.

STEP 1:

  • Take the Transact-SQL course.

  • Download the must know interview questions for data roles study guide and fill it in. (Included in the course)

  • Download and install the GPT and learn all the top SQL interview questions. A GPT is a model I created that is part of ChatGPT to help you ace the SQL Server interview. (Included in the course)

  • SQL is the single most important skill for all the data roles. Spend a lot of time here.

STEP 2: 

  • Learn PowerBI. Take the PowerBI course.

  • Study the exam cram guides included in the course for PL-300.

  • Use the interview prep sheet for acing the interview. Attain PL-300. That’s the PowerBI certification. I know it works because almost every one of my students has passed the exam on the first try.

  • You’ll need to learn as many recent version as possible with a focus on the Fabric implementation.

STEP 3: 

  • Learn Fabric. It’s Microsoft new data centric cloud ecosystem.

  • Take my Fabric course and pass DP-600. That’s the Fabric certification. Yes, I’ve included the cheat sheet for that certification also. It’s at the end of the Fabric course. Study these, you’ll pass the exam I promise.

🥳 Here’s a code to receive $20 off the first month. Yep, that means the first month is only $30 dollars. This price includes:

  • All the courses

  • The study guides

  • The GPT

  • The exam crams

CODE: MEMDAY25

Take control of your future. Nobody else is going to. If you don’t fail often you are doing something wrong. 👏

Stop whining and making excuses. No one gives a shit. If you need some big boy motivation start listening to David Goggins. 🫡

Everything in life is a mind game! Whenever we get swept under by life’s dramas, large and small, we are forgetting that no matter how bad the pain gets, no matter how harrowing the torture, all bad things end.

David Googins