Quick Summary
| Dimension / Taxonomy | Anthropic (Dec 2024) | OpenAI Agents SDK | Andrew Ng / DeepLearning.AI |
| Primary Lens | Conceptual & Architectural Shapes | Versioned SDK Primitives | Strategy & Prompt Loops |
| Control Model | Explicit code paths (Workflows) vs. Dynamic autonomous loops (Agents) | SDK-managed loop with delegated execution | Iterative multi-prompt execution |
| Core Primitives | Chaining, Routing, Parallelization, Orchestrator-Workers, Evaluator-Optimizer | Manager (agents as tools) and Handoffs | Reflection, Tool Use, Planning, Multi-Agent Collaboration |
| Best Used For | Designing deterministic or mixed orchestration in custom code | Rapid prototyping with SDK-driven control flow and delegated tasks | Framing prompt engineering strategies at the model level |
📚 Series Navigation: Agentic Systems
Part 1: Agentic Systems - The Cognitive Architecture
Part 2:
Part 3:
Part 4:
Part 5:
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,
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.
3. The Multi-Agent Layer: (Open AI SDK Patterns)
When a single agent becomes too complex, overburdened by too many tools, or restricted by conflicting system prompts, architectures shift to multi-agent patterns. OpenAI's Agents SDK handles this through two primary primitives. OpenAI's Agents SDK highlights two main multi-agent patterns:
Manager (Agents as Tools):
What it is: A central orchestrator agent delegates subtasks to specialized helper agents. The orchestrator pauses, waits for the helper to return a result, and then resumes its own reasoning.
Why it is used: To compartmentalize instructions. A central agent maintains the global context of the user's request while relying on specialists for domain-specific heavy lifting.
Pros: Centralized state management. It is easy to enforce global guardrails and maintain a consistent tone with the user.
Cons: The manager becomes a bottleneck. The orchestrator remains active throughout, compounding token usage and latency.
Working Example: A "Financial Advisor Agent" acts as the manager. When a user asks for a portfolio review, it delegates a task to a "Web Scraper Agent" to fetch live market news, and another to a "Math Agent" to calculate yield. The Manager synthesizes the final report.
Handoffs
- What it is: A one-way transfer where Agent A passes full control of the interaction to Agent B and steps out of the loop completely. In the OpenAI SDK, handoffs are executed exactly like function/tool calls.
- Why it is used: To route users through distinct domains (e.g., sales vs. support) without keeping all instructions loaded in one massive context window.
- Pros: Highly modular, cost-efficient (the initial agent is dropped from context), and keeps system prompts tightly scoped.
- Cons: Tracking the overall conversation state becomes difficult. If the user wants to return to the original topic, the system requires a reverse handoff.
- Working Example: A "Customer Triage Agent" answers basic questions. When the user says, "I want to cancel my order," the Triage Agent triggers a handoff to the "Refunds Agent," which possesses specific secure billing tools. The Refunds Agent completes the interaction.
Implementation Advice
- Start with a Single Agent: You rarely need multiple agents at the start. Adding tools to a single agent usually resolves most problems with lower complexity.
- Use Multi-Agent Systems Sparingly: Move to a multi-agent structure only when a single agent becomes too complex to manage.
- Enable Observability Early: Log every step and decision (tracing) from day one. Debugging multi-agent loops without detailed execution logs wastes significant development time.
4. Andrew Ng's Four Prompt Strategies
Andrew Ng's framework focusses on maximizing the reasoning capabilities of the underlying model through strategic prompting loops.
Reflection
What it is: The AI critiques its own output (or the output of a peer model) to iteratively improve the quality before showing it to the user.
Why it is used: LLMs often produce flawed "first drafts." Reflection automates the human process of reviewing and refining.
Pros: Yields massive quality improvements for long-form writing, code generation, and complex math.
Cons: Doubles or triples the latency and token cost per turn.
Working Example: A Generator agent writes a blog post. A Critic agent (prompted strictly as an editor) reviews it against a specific rubric and returns feedback. The Generator revises the post based on the critique.
Tool Use
- What it is: Connecting the LLM to external APIs, databases, or execution environments.
- Why it is used: To bridge the gap between static training weights and live, real-world data, enabling the AI to take actual action.
- Pros: Eliminates factual hallucinations by fetching ground-truth data.
- Cons: Requires strict API interface design and robust error handling for timeouts or bad responses.
- Working Example: Prompting a model with access to a get_current_weather(location) function. The LLM pauses its text generation, requests the function execution, receives the JSON data, and formats a human-readable response.
Planning
What it is: Forcing the LLM to generate a step-by-step roadmap before it executes any actions.
Why it is used: To prevent the LLM from getting lost in complex, multi-step goals. It forces the model to load the full context into its working memory.
Pros: Drastically improves success rates for long-horizon tasks.
Cons: Plans can become brittle if the environment changes midway through execution.
Working Example: A prompt instruction stating: "Before writing the code, outline the architecture in 3 steps inside
<plan>tags. Only proceed to Step 1 after the plan is complete."
Multi-Agent Collaboration
What it is: Assigning specific, specialized personas to multiple AI agents and having them communicate with one another to solve a complex problem.
Why it is used: To break down highly complex tasks into domain-specific roles. Instead of one massive prompt trying to do everything, you simulate an organizational structure (e.g., a writer, an editor, and a fact-checker).
Pros: Naturally divides labor and allows for simulated debate or peer review, which often results in significantly higher-quality outputs than a single generalized model.
Cons: Introduces communication overhead, multiplies token consumption rapidly, and can lead to coordination issues if agents get stuck arguing or fail to reach a consensus.
Working Example: A software development task where a "Coder Agent" writes the application logic, a "QA Agent" runs tests and reports bugs back to the coder, and a "Project Manager Agent" decides when the code is stable enough to output to the user.
Note: These concepts describe iterative prompt loops rather than strict software code requirements. They are flexible building blocks, not a fixed step-by-step sequence.
5. System Reliability with LangGraph
While Anthropic and OpenAI dictate the flow of intelligence, frameworks like LangGraph focus on the durability of the underlying software infrastructure.
Durable Execution (Stateful Graphs)
What it is: Modeling agentic workflows as state machines where every step (node) and decision (edge) is automatically saved to a database.
Why it is used: For long-running, asynchronous tasks that take minutes or hours and might be interrupted by rate limits or server crashes.
Pros: Highly fault-tolerant. Systems can pause, resume, and recover gracefully from the exact point of failure.
Cons: Steep learning curve and heavy infrastructure overhead. It is overkill for simple, synchronous API calls.
Working Example: An agent is tasked with analyzing a 500-page PDF. Halfway through, the API hits a rate limit and the server crashes. Because LangGraph persists state, upon restart, the agent resumes processing at page 251 instead of starting over.
Human-in-the-Loop
What it is: Pausing the agent's graph execution to request manual human approval before proceeding.
Why it is used: To ensure safety, compliance, and quality control before executing destructive or high-stakes actions.
Pros: Prevents catastrophic mistakes (e.g., dropping a production database, authorizing a large refund).
Cons: Breaks continuous autonomous execution and requires building a UI for human interaction.
Working Example: An AI proposes a SQL query to update 10,000 user records. Execution stops. A developer reviews the query in a dashboard and clicks "Approve." The graph resumes and executes the query.
Use basic libraries first if you only need standard tool calling. Reserve graph-based platforms like LangGraph for complex, long-running tasks that require persistent state and manual check-ins.
6. The Emerging Interoperability Layer (MCP)
The Model Context Protocol (MCP) represents the shift from isolated agents to a standardized ecosystem.
- What it is: An open, standardized protocol that dictates how AI models connect to and consume external data sources and tools.
- Why it is used: To solve the N-to-N integration problem. Instead of writing custom API wrappers for every new agent framework, developers build one MCP server that any compliant agent can use.
- Pros: True portability. A tool built as an MCP server can be used by Claude Desktop, a custom LangGraph agent, and an enterprise IDE simultaneously.
- Cons: It is an emerging standard requiring developers to host and maintain separate MCP servers alongside their core applications.
- Working Example: You build a local MCP server that exposes your company's internal Confluence wiki. You open Claude Desktop, point it at your local MCP server, and immediately ask questions about your internal documents without writing a single line of custom ingestion code.
The Architect's Bottom Line
Designing agentic systems isn't about choosing one single framework to rule them all; it’s about applying the right pattern to the right problem.
When architecting next AI system, start simple: use Anthropic’s Workflows (Chaining & Routing) for deterministic, reliable business processes. When your workflow requires complex API interactions or bridging real-world data, wrap those in Andrew Ng’s Tool Use and Reflection loops to ensure quality. Only graduate to OpenAI’s Multi-Agent (Manager/Handoff) patterns when a single agent's system prompt becomes too bloated to manage. Finally, if your tasks are asynchronous, long-running, or high-stakes, anchor the entire system in a stateful graph like LangGraph to ensure durability and human oversight.
No comments:
Post a Comment