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
Answer diverse questions: a math problem, a text translation, and a weather question.
- 15% of 240 = 36
- "meeting postponed" = "réunion reportée"
- Probably cloudy. Check the forecast.
[Router] Query classification:
-
"15% of 240" → MathAgent [MathAgent] 240 * 0.15 = 36.00
-
"meeting postponed → French" → TranslationAgent [TranslationAgent] "meeting postponed" = "réunion reportée" (business context)
-
"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.
A router architecture dispatches queries to experts. A single general LLM handles everything "okay," but specialized agents each excel in their own domain.
Create a free account to solve challenges
3 AI-verified challenges for this lesson
This lesson is part of a structured LLM course.
My Learning Path