Session 6 · Bonus Material

Advanced
Agent Patterns

From ReAct reasoning to multi-agent systems — the patterns that power production AI.

ReAct — Think Before You Act

The ReAct pattern interleaves reasoning with action. Instead of blindly calling tools, the agent thinks about what it needs, acts, observes the result, and adjusts. This is how the best agents work.

Query
"Research the impact of AI on healthcare"
Thought
I need to find recent data on AI's impact on healthcare. Let me start by searching for peer-reviewed studies and industry reports from the last 2 years.
Action
search_web("AI healthcare impact 2025 studies statistics")
Observation
Found 12 results. Key finding: WHO report says AI diagnostics reduce misdiagnosis by 30%. McKinsey estimates $150B value by 2026.
--- cycle 2 ---
Thought
Good quantitative data, but I should also look at specific use cases and any risks/concerns to give a balanced analysis.
Action
search_web("AI healthcare risks bias clinical trials 2025")
Observation
FDA flagged bias in 3 diagnostic models. JAMA study found 40% of AI tools lacked adequate validation on diverse populations.
--- cycle 3 ---
Thought
Now I have both benefits and risks. Let me calculate the net impact figures and synthesize a comprehensive answer.
Action
calculator("150000000000 * 0.7") — adjusting for adoption barriers
Observation
Realistic near-term value: $105B accounting for regulatory and adoption headwinds.
FINAL ANSWER: Synthesized a balanced report covering diagnostic improvements (30% fewer errors), market value ($105-150B), and critical risks (bias, validation gaps). Three Thought-Action-Observation cycles produced a nuanced analysis.

Why does this matter?

Naive Agent

No reasoning loop
Step 1: Receive query "Research AI in healthcare"
Step 2: Call search_web("AI healthcare")
Step 3: Dump the first 3 search results verbatim to the user. No analysis, no evaluation, no follow-up.
One search, zero reasoning. Shallow and incomplete.
VS

ReAct Agent

Think + Act + Observe
Cycle 1: Plans search strategy, finds quantitative data on benefits
Cycle 2: Identifies gap (risks), searches for balanced perspective
Cycle 3: Runs calculations, adjusts projections for realism
Synthesis: Delivers a structured, balanced report with citations
3 cycles of reasoning. Thorough, balanced, and actionable.

Chain-of-Thought Planning

Before executing anything, the best agents plan first. They decompose complex tasks into discrete steps, then execute them one by one. Planning before acting dramatically reduces errors and wasted effort.

Task
"Write a competitive analysis report for our SaaS product"

Identify key competitors

Search for direct and indirect competitors in the SaaS space. Compile a list of the top 5 by market share.

Plan Execute: search_web + analyze

Gather feature comparisons

For each competitor, catalog their pricing, core features, and unique selling points from their websites and reviews.

Plan Execute: scrape_page x5

Analyze market positioning

Map each competitor on a price-vs-features matrix. Identify market gaps and positioning opportunities.

Plan Execute: analyze + calculate

Assess strengths and weaknesses

SWOT analysis for each competitor. Pull from user reviews, G2 ratings, and social sentiment.

Plan Execute: search_reviews + summarize

Synthesize final report

Combine all findings into a structured report with executive summary, comparison tables, and strategic recommendations.

Plan Execute: write_report
40% fewer errors
Agents that plan before acting produce significantly fewer errors and require fewer correction cycles. The "plan then execute" pattern mirrors how expert humans approach complex tasks — they don't just start typing.
Source: Wang et al., "Plan-and-Solve Prompting" (ACL 2023) — showed chain-of-thought planning improved accuracy by 40% on multi-step reasoning benchmarks vs. zero-shot baselines.

Multi-Agent Architectures

One agent is powerful. But teams of agents — each with a specialized role — can tackle problems no single agent can handle. Here are three production patterns.

Pipeline (Sequential)

Each agent hands off to the next

Like an assembly line. Each agent has one job and passes its output to the next specialist. Simple, predictable, easy to debug.

Researcher
raw data
Writer
draft
Editor
polished
Final Output
delivered

Debate (Adversarial)

Agents challenge each other

One agent proposes, another critiques, a third synthesizes. The tension between viewpoints produces stronger, more balanced outputs.

proposes critiques refines
Agent A: Proposer
Agent B: Critic
Agent C: Synthesizer

Orchestrator (Manager + Workers)

Coordinator delegates to specialists

A manager agent analyzes the task, decides which specialists to invoke, coordinates their work, and assembles the final output. Most flexible pattern.

Orchestrator
Research
Analysis
Writing
Coding

The Business Org Chart Analogy

Pipeline
= Assembly Line

Each station does one thing well and passes the product forward. Toyota Production System meets AI.

Debate
= Peer Review Board

Proposals get challenged by independent reviewers. Stronger outputs through constructive friction.

Orchestrator
= Project Manager + Team

A PM evaluates the task, assembles the right team, delegates work, and delivers the final product.

The Evolution — From NanoClaw to Multi-Agent

We've been building toward this all semester. Each session added a new layer of capability. Here's the progression from simple tool use to autonomous agent networks.

Session 4
🔧

Tool Use

LLM + Calculator + Stock Lookup. The model decides which tool to call.

Session 6
🧠

ReAct Agent

LLM + Reasoning Loop + Research Tools. The model thinks, acts, and observes in cycles.

Production
👥

Multi-Agent Systems

Teams of specialized agents coordinating on complex workflows.

Future
🌐

Autonomous Networks

Self-organizing agent swarms that discover, recruit, and coordinate other agents.

MCP — The USB-C of AI

The Model Context Protocol (MCP) is an open standard that lets any AI model connect to any tool through a single, universal interface — just like USB-C replaced a drawer full of different cables.

Before MCP

ChatGPT ---custom-api--- Slack
Claude ---custom-api--- GitHub
Gemini ---custom-api--- Google Drive
ChatGPT ---custom-api--- Salesforce
Claude ---custom-api--- Slack
Gemini ---custom-api--- Salesforce
ChatGPT ---custom-api--- Database
Claude ---custom-api--- Google Drive
N models x M tools = N*M custom integrations

After MCP

MCP Standard Protocol
Slack
GitHub
Google Drive
Salesforce
PostgreSQL
Notion
Jira
Stripe
Any AI model connects to any tool
through one universal protocol
N + M implementations total. Build once, connect everywhere.
1,000+
MCP servers
available
Open
Standard —
anyone can build
Anthropic
Created by
the Claude team
Universal
Works with any
LLM provider

When to Use What

Not every problem needs a multi-agent system. Use the simplest approach that gets the job done. Here's your decision guide.

Simple, well-defined task
Direct LLM Call
Needs external data or calculations
Single Agent + Tools
Complex reasoning with uncertain steps
ReAct Agent
Multi-step workflow with clear stages
Chain-of-Thought + Tools
Different expertise areas needed
Multi-Agent System