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.

Core insight:
Specialized roles = different behavior. A critic-prompted agent catches errors that a single agent would miss. Role separation is how LLM systems ship reliably.

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"

🏦
Real scenario
HDFC Bank research brief with planner/executor/critic

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."

planner_agent.py Planner breaks task into ordered sub-tasks

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.

executor_agent.py Executor runs plan, calls tools, returns structured data

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.

critic_agent.py Critic reviews Executor output, spots hallucinations

Step 4: Final memo (only after Critic approval)

Final output (after critic approval)
HDFC Bank Q3 2025 Earnings Brief HDFC Bank reported strong Q3 2025 results with net interest income of ₹18,500 Cr, up 7.6% YoY from ₹17,200 Cr. Net profit reached ₹5,200 Cr, representing 8.3% growth compared to ₹4,800 Cr in Q3 2024. Loan advances grew 9.2% to ₹8.4 Lakh Cr. Asset quality remained stable with gross NPAs at 1.23%. The bank's return on assets (RoA) improved to 2.85% from 2.71% YoY. Operating expenses grew 5.1%, outpaced by revenue growth, signaling operating leverage. The result demonstrates resilience in credit demand and disciplined cost management.

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.

User Request
→
Planner (outputs Plan)
Plan
→
Executor (outputs ExecutorResult)
ExecutorResult
→
Critic (outputs CriticReview)
CriticReview (approved)
→
User (final result)
Pattern:
Each agent outputs a Pydantic model. The next agent receives the model, not a string summary. Validation happens at every handoff. Hallucinations are caught early.

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.

orchestrator.py Routes request through planner/executor/critic pipeline

Kenya example: Jumia product listing with agent roles

🛒
Real scenario
Jumia Kenya: create product listings with planner/executor/critic

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?

Why it works:
Planner ensures no step is skipped. Executor gathers real data. Critic catches overpricing or misclassification before items go live.

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.

Prevention pattern:
Test each agent's system prompt in isolation before connecting them. Verify the Planner's output, then run the Executor on one step, then test the Critic's logic. Don't assume orchestration works if pieces work separately.

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 Decomposition Reliability & Validation Multi-Agent Orchestration Error Mitigation
🎯 Mini Challenge: Build a data entry validator

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

Question 1 of 5
Why is role separation (Planner/Executor/Critic) more reliable than a single agent?
Question 2 of 5
What should agents pass between each other?
Question 3 of 5
What is the Planner's job?
Question 4 of 5
What does the Critic do if the Executor's output contains a hallucination?
Question 5 of 5
What is the biggest risk of a weak Critic prompt?
0
/5
Great! You understand multi-agent role separation and how to build reliable systems.
Africa & India's Best AI Academy
🤖 AI-first 🎓 Placement Assistance

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 →