Showing posts with label LLM agents. Show all posts
Showing posts with label LLM agents. Show all posts

Sunday, 13 September 2026

Agentic System Design Patterns: A Practical Guide


Quick Summary

Dimension / TaxonomyAnthropic (Dec 2024)OpenAI Agents SDKAndrew Ng / DeepLearning.AI
Primary LensConceptual & Architectural ShapesVersioned SDK PrimitivesStrategy & Prompt Loops
Control ModelExplicit code paths (Workflows) vs. Dynamic autonomous loops (Agents)SDK-managed loop with delegated executionIterative multi-prompt execution
Core PrimitivesChaining, Routing, Parallelization, Orchestrator-Workers, Evaluator-OptimizerManager (agents as tools) and HandoffsReflection, Tool Use, Planning, Multi-Agent Collaboration
Best Used ForDesigning deterministic or mixed orchestration in custom codeRapid prototyping with SDK-driven control flow and delegated tasksFraming prompt engineering strategies at the model level



📚 Series Navigation: Agentic Systems

Part 1: Agentic Systems - The Cognitive Architecture

Part 2: Agentic Systems – The Core System Modules

Part 3: Agentic Systems – Core Agentic Design Patterns (You are here)

Part 4: Agentic Systems – Enterprise Safeguards and Security (Stay Tuned)

Part 5: Agentic Systems – End to End Working example (Stay Tuned)




1. Why Companies Define "Agentic Patterns" Differently

Searching for "agentic AI design patterns" yields three different explanations from Anthropic, OpenAI, and Andrew Ng. These frameworks overlap, but they serve different purposes:

  • Anthropic: Focuses on architecture patterns you build yourself in custom code.

  • OpenAI: Focuses on pre-built software features inside their official code library (SDK).

  • Andrew Ng: Focuses on prompt engineering strategies to improve model outputs.

Anthropic's guide, Building Effective Agents, highlights that successful teams avoid overly complex frameworks. Instead, they build with simple, clear design patterns. To build reliable systems, architects must understand not just what these patterns are, but when and how to deploy them.


2. Anthropic's Control Flow: Workflow vs. Agent

Anthropic divides AI architectures into two categories based on who controls the path of execution: the developer (Workflows) or the LLM (Agents).

Workflows (Predefined Paths)

  • What it is: A structured pipeline where the developer dictates the control flow via code. The AI executes specific sub-tasks along a predetermined path.

  • Why it is used: For predictable, repeatable business processes where reliability, auditability, and fixed SLAs are prioritized over absolute autonomy.

  • Pros: Highly reliable, easy to debug, testable, and significantly cheaper in token costs because you only invoke the LLM for specific steps.

  • Cons: Rigid. If the real-world input deviates from the expected steps, the workflow will fail because it cannot invent a new path.

  • Working Example (Prompt Chaining): A document processing pipeline.
    Step 1: An LLM extracts entities from an invoice.
    Step 2: Standard Python code checks those entities against a SQL database.
    Step 3: A second LLM formats the final JSON payload.
    The LLM never decides what happens next; it only completes its assigned step.

Agents (Autonomous Loops)

  • What it is: An autonomous system where the LLM drives the control flow. It uses a loop of perception, reasoning, and action—dynamically choosing tools and reacting to environment feedback until it determines the goal is met.

  • Why it is used: For open-ended tasks with an unknown number of steps, such as deep web research or multi-file code refactoring (e.g., SWE-bench tasks).

  • Pros: Highly flexible. It can adapt to errors, self-correct, and navigate edge cases without needing explicit hardcoding.

  • Cons: Prone to unpredictable latency, high token costs, and getting stuck in hallucinated, infinite loops. Harder to debug.

  • Working Example (Coding Agent): The LLM is given a task to fix a bug. It writes code, calls a tool to run unit tests, reads the test failure output, reasons about the error, and rewrites the code. It continues this loop entirely on its own until the tests pass.

Key Workflow Patterns

Prompt Chaining

  • What it is: Running tasks in a sequential pipeline where the output of one LLM call becomes the direct input for the next.

  • Why it is used: To break complex reasoning into smaller, focused steps, reducing the chance of the LLM losing track of instructions.

  • Pros: Easy to implement, highly predictable, and allows developers to inject standard code (like validation scripts) between LLM steps.

  • Cons: Sequential execution increases total latency.

  • Working Example: Step 1 extracts user intent from an email. Step 2 drafts a reply based on that intent. Step 3 translates the reply into Spanish.

Routing

  • What it is: Using an initial LLM (or traditional classifier) to evaluate an input and route it to one of several specialized downstream workflows.

  • Why it is used: To handle broad, varied inputs (like a general customer support inbox) by directing them to specialized, narrowly-prompted experts.

  • Pros: Keeps downstream prompts small and highly targeted, which improves accuracy and reduces cost.

  • Cons: If the router misclassifies the input, the entire downstream process fails.

  • Working Example: A router reads a support ticket. If it's a billing issue, it routes to a workflow with access to the Stripe API. If it's a technical bug, it routes to a workflow that searches GitHub issues.

Parallelization

  • What it is: Running multiple independent LLM calls at the exact same time, then aggregating their outputs.

  • Why it is used: To drastically reduce latency when a task can be broken into independent chunks.

  • Pros: Speed. It turns a process that would take 60 seconds sequentially into one that takes 10 seconds.

  • Cons: Can quickly hit API rate limits if you fan out too many concurrent requests.

  • Working Example: A system needs to evaluate a startup's pitch deck. It simultaneously launches one prompt to analyze the financials, one to evaluate the team, and one to check market fit. A final prompt merges the three analyses.

Orchestrator-Workers

  • What it is: A dynamic form of parallelization where a central "Orchestrator" LLM analyzes the task, decides how many and what kind of worker tasks are needed, and synthesizes their results.

  • Why it is used: When the sub-tasks cannot be predicted in advance and must be dynamically generated based on the input.

  • Pros: Highly flexible while still maintaining structured execution.

  • Cons: High token consumption and complex to orchestrate programmatically.

  • Working Example: A user asks, "What is the weather like in New York, London, and Tokyo?" The Orchestrator spins up three separate worker tasks to fetch the weather for each city, waits for them all to return, and writes the final summary.