Lesson 7

Agent Architectures

MRKL, Reflexion, LATS

The Problem: Building an AI agent isn't just about the AI itself. How do you structure the whole system? How do agents communicate? Who's in charge? Bad architecture leads to chaos, even with great AI.

The Solution: Organizational Patterns

Just like companies have organizational structures, AI agent systems have architectures. A single agent might follow the ReAct pattern, while a multi-agent system needs coordination and routing. Regardless of shape, every agent relies on function calling to interact with the outside world.

Think of it like different company structures:

  • 1. Single Agent (Solopreneur): One AI does everything. Simple but limited.
  • 2. Sequential (Assembly Line): Agents work one after another. Task passes down the line.
  • 3. Hierarchical (Traditional Corp): Manager agents delegate to worker agents.
  • 4. Collaborative (Flat Startup): Agents discuss and reach consensus together.
  • 5. Supervisor (Scrum Team): One coordinator routes tasks to specialists.
  • 6. Graph-based (LangGraph): Agents as graph nodes with conditional edges. Supports loops, branching, human-in-the-loop, and persistent state across runs.
  • 7. Crew-based (CrewAI): Role-playing agents with backstories and goals. The framework handles task delegation, result passing, and quality checks automatically.
  • 8. Swarm Handoffs (OpenAI): Minimal overhead: agents hand off to each other with context. No central orchestrator. Best for customer service routing and domain-specific pipelines.

Choosing an Architecture

  • Task complexity: Simple tasks → single agent; complex → multi-agent
  • Need for oversight: High-stakes → hierarchical with approval steps
  • Parallelization: Independent subtasks → collaborative or supervisor
  • Specialization: Different skills needed → specialized agents
  • CrewAI Framework: Define agents as "crew members" with roles (researcher, writer, reviewer). Each agent has a backstory, goal, and tools. The crew follows a process (sequential, hierarchical, or consensual).
  • LangGraph: Graph-based agent orchestration from LangChain. Agents are nodes, edges define transitions. Supports cycles, conditional routing, human-in-the-loop checkpoints, and persistent state.
  • Swarm Pattern: Lightweight multi-agent handoffs (OpenAI Swarm). Each agent handles its domain, passes context to the next via handoff functions. No central orchestrator needed.

Fun Fact: The most advanced AI systems often use "mixture of experts" — like having many specialist consultants on call. A router figures out which expert to ask for each question. This is how models like GPT-4 handle such diverse tasks!

Try It Yourself!

Explore the interactive diagram below to see how different architectures handle the same task. Notice the tradeoffs between simplicity, control, and parallelism!

Try it yourself

Interactive demo of this technique

Technique Comparison
Demo Mode
Pre-recorded responses
TaskBeginnerAnalysis

Answer diverse questions: a math problem, a text translation, and a weather question.

Without technique
Without technique
Prompt
1. What is 15% of 240? 2. Translate "meeting postponed" to French 3. Will it rain tomorrow in New York?
Response
  1. 15% of 240 = 36
  2. "meeting postponed" = "réunion reportée"
  3. Probably cloudy. Check the forecast.
Tokens:52/48
Time:520ms
Quality:
With Architectures
With technique
Prompt
Router agent. Determine each query type and route to a specialized agent. Agents: - MathAgent: mathematical calculations - TranslationAgent: translations - WeatherAgent: weather (with API access) Queries: 1. What is 15% of 240? 2. Translate "meeting postponed" to French 3. Will it rain tomorrow in New York?
Response

[Router] Query classification:

  1. "15% of 240" → MathAgent [MathAgent] 240 * 0.15 = 36.00

  2. "meeting postponed → French" → TranslationAgent [TranslationAgent] "meeting postponed" = "réunion reportée" (business context)

  3. "Rain in New York tomorrow" → WeatherAgent [WeatherAgent] → get_forecast("New York", "tomorrow") ← { "precipitation": 65%, "type": "rain", "temp": 12°C } Yes, rain is expected in New York tomorrow (65% chance), around 12°C.

All 3 queries handled by specialized agents.

🧠Router classifies queries: math, translation, weather
👁️Each query routed to a specialized agent
👁️WeatherAgent uses API — gives accurate forecast instead of guessing
"Router + experts" architecture gives better results for each task type
Tokens:105/185
Time:2800ms
Quality:
Why this works

A router architecture dispatches queries to experts. A single general LLM handles everything "okay," but specialized agents each excel in their own domain.

1 / 2

Lesson Quiz

1 of 3

1.What characterizes a supervisor architecture in multi-agent systems?

Practice Challenges

Create a free account to solve challenges

3 AI-verified challenges for this lesson

Related lessons:ReactPlanningMulti Agent

This lesson is part of a structured LLM course.

My Learning Path