Session 8 — Homework

Extend Your Multi-Agent Pipeline

Four tasks to deepen your understanding of multi-agent systems. Build a 4th agent, test reliability, and design for your industry.

4 tasks • Estimated time: 90–120 minutes • Due before Session 9
1
2
3
4
1
2
3
4

Add a 4th Agent to Your Pipeline

Your pipeline has Researcher → Analyst → Editor. Add a 4th agent. Choose one:

Researcher
Analyst
Editor
Your 4th
Agent

Choose your 4th agent

Fact-Checker

Cross-references claims against known data. Place between Analyst and Editor.

📋
Summarizer

Produces a 1-paragraph executive brief. Place after Editor.

🎯
Domain Expert

Adds industry-specific context (e.g., healthcare, finance). Place between Researcher and Analyst.

Starter code

Define your 4th agent’s prompt and wire it into the pipeline.

extend_pipeline.py
1# Choose your 4th agent and define its prompt
2FOURTH_AGENT_PROMPT = """You are a specialized [ROLE] Agent.
3
4Your job: [DESCRIBE WHAT IT DOES]
5
6Input: [WHAT IT RECEIVES]
7
8Output format:
9[DEFINE STRUCTURED OUTPUT]
10
11IMPORTANT: [KEY CONSTRAINT]"""
12
13# Modify run_pipeline() to include the 4th agent
14def run_pipeline_v2(query):
15 # Stage 1: Researcher
16 researcher_output = call_agent(RESEARCHER_PROMPT, query, "Researcher")
17
18 # Stage 2: YOUR 4TH AGENT (if it goes here)
19 # fourth_output = call_agent(FOURTH_AGENT_PROMPT, ..., "Your Agent")
20
21 # Stage 3: Analyst
22 analyst_output = call_agent(ANALYST_PROMPT, ..., "Analyst")
23
24 # Stage 4: Editor
25 editor_output = call_agent(EDITOR_PROMPT, ..., "Editor")
26
27 return {...}
28
29# Test with 3 business questions
30questions = [
31 "Impact of AI on supply chain management",
32 "Remote work trends and productivity data",
33 "Sustainable business practices ROI"
34]
35
36for q in questions:
37 result = run_pipeline_v2(q)
38 print(f"Query: {q}")
39 print(f"Quality Score: [check editor output]")
40 print("---")
3 color-coded sections. Agent prompt (cyan) — define your new agent’s role. Pipeline logic (green) — wire in the 4th stage. The yellow line is where your agent goes. Test harness (magenta) — run on 3 questions.

Deliverable

💡 Placement matters

Where you insert the 4th agent changes the pipeline’s behavior. A Fact-Checker between Analyst and Editor catches errors before editing. A Domain Expert between Researcher and Analyst enriches the analysis. Think about information flow.

1
2
3
4

Document Information Distortion

Run your pipeline 5 times on the SAME question. Document how outputs differ. This is the “telephone game” in action.

Record your results

Use this table format in your notebook. Fill in each row after each pipeline run.

Run # Key Facts Found Quality Score Unique Claims Consistent Claims
1 fill in... fill in... fill in... fill in...
2 fill in... fill in... fill in... fill in...
3 fill in... fill in... fill in... fill in...
4 fill in... fill in... fill in... fill in...
5 fill in... fill in... fill in... fill in...

Automation snippet

distortion_test.py
1# Run the same question 5 times and collect results
2test_question = "Impact of AI on supply chain management"
3results = []
4
5for i in range(5):
6 print(f"\n{'='*50}")
7 print(f"Run {i+1} of 5")
8 print(f"{'='*50}")
9 result = run_pipeline(test_question)
10 results.append(result)
11
12# Compare: What changed between runs?
13for i, r in enumerate(results):
14 print(f"\nRun {i+1}:")
15 print(f" Editor output: {r['editor'][:200]}...")

Analysis questions

Answer each of these in your submission:

⚠ The point is variation, not perfection

If every run produces identical output, try setting temperature=1 or using a more open-ended question. LLMs are non-deterministic — the question is how different, not whether they differ.

1
2
3
4

Design a Multi-Agent System for Your Industry

Propose a multi-agent system for your target industry (the one you’ll use for your final project). Think like an architect — agents, handoffs, human gates, and cost.

Design Template
1.
Industry
[YOUR INDUSTRY] — the one you’ll use for your final project
2.
Use Case
[SPECIFIC PROBLEM TO SOLVE] — what multi-step process would benefit from agents?
3.
Agent Roles
For each agent: Role, Input, Output, System prompt summary (2–3 sentences)
4.
Handoff Logic
Agent 1 → Agent 2: What data passes? What format?
5.
Human Gates
Where should a human review before proceeding? What decisions are too important for full automation?
6.
Cost Estimate
API calls per run, estimated tokens, cost per run at ~$3/M input, ~$15/M output

Agent design template

design_template.txt
1Industry: [YOUR INDUSTRY]
2Use Case: [SPECIFIC PROBLEM TO SOLVE]
3
4Agent 1: [ROLE]
5 - Input: [What it receives]
6 - Output: [What it produces]
7 - System prompt summary: [2-3 sentences]
8
9Agent 2: [ROLE]
10 - Input: [What it receives from Agent 1]
11 - Output: [What it produces]
12 - System prompt summary: [2-3 sentences]
13
14Agent 3: [ROLE]
15 ...
16
17Handoff Logic:
18 - Agent 1 → Agent 2: [What data passes, what format]
19 - Agent 2 → Agent 3: [What data passes]
20
21Human Gates:
22 - [Where should a human review before proceeding?]
23 - [What decisions are too important for full automation?]
24
25Cost Estimate:
26 - API calls per run: [NUMBER]
27 - Estimated tokens per run: [NUMBER]
28 - Cost per run at ~$3/M input, ~$15/M output: $[ESTIMATE]

Example design

☁ CloudSync — Customer Support Pipeline

Industry:
SaaS / Cloud Computing
Use Case:
Automated customer support ticket resolution
Agent 1:
Triage Agent — Classifies incoming tickets by severity and category (billing, technical, account). Routes to the right team.
Agent 2:
Research Agent — Searches knowledge base and past tickets for relevant solutions. Pulls account context.
Agent 3:
Response Agent — Drafts a customer-facing reply using the research. Matches brand voice and tone.
Agent 4:
QA Agent — Checks accuracy, tone, and compliance. Flags responses that need human review.
Human Gate:
All billing-related and account-deletion responses require human approval before sending.
Cost:
4 API calls × ~2K tokens each = ~8K tokens/run ≈ $0.14 per ticket
✅ Any architecture works

The pipeline is the baseline, but feel free to propose a debate pattern (two agents argue), an orchestrator pattern (manager agent delegates), or a hybrid. Just explain why your architecture fits the use case.

1
2
3
4

Claude Code’s Team Feature

Read about Claude Code’s multi-agent “team” feature and the orchestrator pattern. This is how real production systems coordinate multiple AI agents.

Reading Assignment

  1. Read the Claude Code Subagents documentation on Anthropic’s site.
  2. Also review the Building Effective Agents guide — focus on the orchestration section.
  3. Think about how these patterns connect to what you built in Session 8’s lab.

Deliverable

Write one paragraph (5–8 sentences) explaining how Claude Code’s team feature implements the orchestrator pattern from Session 6. Include:

📝 Keep it concise

One paragraph is enough. The goal is to show you understand the orchestrator pattern and can recognize it in real products — not to write an essay. Connect what you read to the architectures we discussed in Session 6 (Pipeline, Debate, Orchestrator).

FAQ & Common Issues

Click any question to expand the answer.

📝 How long should my 4th agent’s prompt be?
Similar to the others — 10–20 lines. Focus on role, input format, output format, and key constraints. A great agent prompt is specific enough that the LLM knows exactly what to do, but flexible enough to handle different inputs.
🎲 My pipeline gives different results every time — is that a bug?
No! That’s the point of the Telephone Game exercise. LLMs are non-deterministic. The question is: how different? Use temperature=0 for more consistency. The goal of Task 2 is to measure and document this variation, not eliminate it.
💰 How do I estimate API costs?
Count your agents × average tokens per call. With claude-sonnet-4-20250514 at ~$3/M input and ~$15/M output, a 3-agent pipeline with ~2K tokens each costs roughly $0.10 per run. A 4-agent pipeline costs ~$0.14. For your design in Task 3, multiply agents × tokens × expected daily runs.
🔄 Can I use a different architecture (debate, orchestrator) instead of pipeline?
Absolutely! The pipeline is the baseline for Tasks 1 and 2, but for Task 3’s design exercise, feel free to propose any architecture that fits your use case. Debate patterns work great for adversarial checking (e.g., code review), orchestrators for complex routing (e.g., customer support). Just explain why you chose it.

Key Takeaways

Agent teams mirror org charts. Division of labor, specialization, and coordination costs apply to AI agents just like human teams. Design your agent system like you’d design a department.

Watch for the telephone game. Information degrades across agents. Citation chains and confidence propagation are your safeguards against compounding errors.

Multi-agent isn’t always better. Each agent adds latency, cost, and complexity. Use the decision framework: multi-agent for complex, multi-expertise tasks. Single-agent for everything else.

The pipeline pattern is your workhorse. Research → Analysis → Review is the most common multi-agent pattern. Master it and you can adapt it to any domain.

4
agents in pipeline
5
distortion runs
1
industry design
3
architectures learned