Why single agents struggle with complex tasks
In Lesson 14, you built an agent that could fetch data and write code. It worked for simple tasks: "Get me the last 5 transactions." But complex tasks like "Write a brief on HDFC bank's Q3 earnings" hit a wall. One agent tries to do everything at once: fetch the filing, extract metrics, compare with prior quarter, draft the memo. Hallucinations compound across all those steps.
Think like a human team working on a research project. You don't have one person do everything. You have a planner break down the task, an executor who gathers sources, a critic who fact-checks. Each role has a specialized system prompt and different accountability.
Three canonical agent roles
Every complex agentic workflow uses this split:
1. Planner Agent
System prompt: "You are a research planner. Break tasks into precise, ordered steps."
Job: Read the user's goal. Emit a structured plan—not advice, but a numbered list of concrete sub-tasks the Executor will run. Planner never executes tools itself.
Output: Pydantic list of steps with description, dependencies, and required data.
2. Executor Agent
System prompt: "You are a precise task executor. Do exactly what you're told. Use tools to fetch real data. Report facts, not opinions."
Job: Take one step at a time from the Plan. Call tools, process results, hand off to the Critic. Never improvise—follow the plan.
Output: Structured data (Pydantic objects) from each step. Pass facts downstream, not summaries.
3. Critic Agent
System prompt: "You are a senior technical reviewer. Your job is to spot errors, inconsistencies, and hallucinations. Flag anything you can't verify."
Job: Review the Executor's output against the facts. Call tools to double-check claims. Approve or reject. If rejected, loop back to Executor with corrections.
Output: Approved result + flags, or rejection with required fixes.
Worked example: "Write a brief on HDFC Q3 earnings"
User request: "Write a 200-word brief on HDFC Bank's Q3 2025 earnings, including key metrics and YoY comparisons."
Single agent approach (fails): Agent tries to fetch filing + write memo in one turn. Hallucination risk is high; no verification step.
Multi-agent approach (reliable): Planner breaks it into steps → Executor gathers real data → Critic verifies before outputting.
Step 1: Planner decomposes the task
System prompt includes: "Break research tasks into numbered steps. Each step should be executable by a tool-using agent. List dependencies."
Step 2: Executor runs the plan, fetches real data
Executor is given the plan and calls tools step-by-step. Each step returns structured data (Pydantic objects), not free text.
Step 3: Critic reviews for accuracy
Critic sees the Executor's output and verifies it. If a number seems off, Critic calls the tool to double-check. If approved, the memo gets drafted.
Step 4: Final memo (only after Critic approval)
How data flows: Pydantic objects, not strings
Critical rule: agents pass structured Pydantic objects, not free text. Why? Free text is easy to hallucinate. Pydantic objects enforce shape and let you validate at each stage.
Orchestrator: routing between agents
The orchestrator is a state machine that routes the request through Planner → Executor → Critic → User. It holds the chat sessions for each agent and passes outputs between them.
Kenya example: Jumia product listing with agent roles
Task: "Create optimized Jumia Kenya product listings for these 5 items: shoes, phone case, water bottle, backpack, headphones. Include description, price (in KSh), category, stock level."
Planner breaks it into: (1) validate product names, (2) fetch real pricing from competitors, (3) write SEO-optimized descriptions, (4) assign Jumia categories, (5) format as CSV for bulk upload.
Executor calls tools to scrape competitor prices, fetch product categories from Jumia's API, write descriptions via an LLM call.
Critic checks: Are prices reasonable (within market range)? Are descriptions unique (not copy-paste)? Are categories correct? Is stock realistic?
Common failure modes and how to avoid them
Three things go wrong in multi-agent systems:
1. Critic rubber-stamping
The Critic agent approves everything without actually checking. This happens when the Critic's system prompt is weak ("Just approve if it looks reasonable"). Fix: Make the Critic's prompt explicit: "You MUST call tools to verify every number. If you cannot verify, reject."
2. Planner being too granular
Planner breaks task into 50 tiny steps. Executor spends all its context tokens on sub-tasks and forgets the original goal. Fix: Limit Planner to 3–5 high-level steps, not 50 micro-steps.
3. Executor getting stuck in loops
Executor calls a tool, gets no result, calls again, and again. The orchestrator never times out. Fix: Add a max_retries counter and a 30-second timeout per executor call.
Next: message passing protocols (Lesson 16)
You've built the roles. But what if the Executor needs to ask the Planner a clarifying question? Or the Critic needs to ask the Executor to re-fetch data from a different source? That's where message passing protocols come in—agents can now talk to each other in a standardized way, not just in a linear pipeline. Lesson 16 covers request-response contracts and async message queues.
How AI systems use this
Every production AI system that needs to be reliable uses role separation. ReACT agents (Reasoning + Acting) use a critic loop. AutoGPT uses a planner-executor-evaluator pattern. Constitutional AI training uses a critic model to rate completeness. When you see "alignment" or "reward model" in papers, you're seeing a critic agent in disguise. The reason: a single LLM is creative but untrustworthy. A specialized critic LLM is slow but accurate. You combine both.
Task: Design a 3-agent system (Planner, Executor, Critic) to validate a CSV of 100 customer records for a Hyderabad bank:
1. Planner: Break validation into steps (check for missing emails, validate phone format, check age range, verify account types).
2. Executor: Read CSV, apply checks, return counts of valid/invalid rows.
3. Critic: Sample 5 flagged rows, manually verify them, report if Executor was correct.
Write the Pydantic models for Plan, ExecutorResult, and CriticReview. Do not implement the full orchestrator—just the schemas and one example agent call.
Hint: Each Pydantic class should match the agent's output shape. Planner → Plan (steps). Executor → ExecutorResult (valid_count, invalid_count, flagged_rows). Critic → CriticReview (approved, issues_found). Start with the schemas; orchestration comes later.
Test your knowledge
You've split agent roles.
Now connect them with message passing.
Join the Best AI Program: The AI-Era Agentic Engineer — 5 months, fully online, with placement assistance. Week 1 is free.
Explore The AI-Era Agentic Engineer →