New Leaf AnalyticsHR & Workforce Intelligence
BYU-Idaho DS 295R Agent Engineering

Multi-Agents: Subagents, Handoffs, and Research Pipelines

Unit 1, Lesson 8 — Hands-on architecture curriculum designed for collegiate AI engineering.

Course Module Learning Outcomes

Mastering Multi-Agent System Design

  • Understand what multi-agent systems are and when they are strictly necessary.
  • Identify architectural failure modes where a single agent collapses.
  • Build a production-grade multi-agent research pipeline with role isolation.
  • Implement coordinated manager-subagent orchestration in Python and LangChain.

Lesson Breakdown

15 MINUTES
Lecture

When Multi-Agents Are Necessary vs Over-Engineering.

15 MINUTES
Concept Deep Dive

Context window isolation & subagent boundaries.

25 MINUTES
Guided Coding

Building the Python research pipeline architecture.

20+ MINUTES
Lab Activity

Extending the pipeline with external tool integration.

Core Bottleneck

The Problem: When One Agent Fails

Consider a realistic production task: "Research AI trends in 2026, evaluate the most important ones, and write a professional report with sources."

Single Agent Overload

When forced to search, evaluate sources, decide relative importance, synthesize reasoning, and compose a final paper in a single prompt loop, a single agent breaks down with:

  • Weak and unverified sourcing
  • Hallucinated facts masquerading as citations
  • Muddled reasoning mixed into prose writing
  • No clear checkpoint for debugging failures
Key Engineering Insight

The Multi-Agent Research Pipeline

Production AI engineering separates concerns cleanly into specialized roles:

  • Planner Agent: Breaks complex prompts into subtopics.
  • Research Agent: Executes focused fact retrieval in parallel.
  • Analyst Agent: Evaluates, cross-checks, and ranks findings.
  • Writer Agent: Compiles final report with clean formatting.

Guided Implementation: Multi-Agent Research System

Below is the canonical pipeline pattern taught in the DS 295R course, wrapping specialized agents as tools orchestrated by a top-level manager.

pipeline.pyPython 3.11 / LangChain
# Step 1: Create Specialized Subagents
from langchain.agents import create_agent
from langchain.tools import tool

research_agent = create_agent(
    model="google_genai:gemini-2.5-flash",
    system_prompt="""You are a research agent. ONLY gather facts.
- No opinions
- No summaries
- Return bullet points with verifiable citations.""",
    tools=[search_web, read_local_files]
)

analysis_agent = create_agent(
    model="google_genai:gemini-2.5-flash",
    system_prompt="""You are an analyst.
Take raw research and:
- Identify key strategic insights
- Compare conflicting findings
- Rank importance by business impact."""
)

writer_agent = create_agent(
    model="google_genai:gemini-2.5-flash",
    system_prompt="""You are an executive writer.
Synthesize analysis into a structured executive report."""
)

# Step 2: Wrap Subagents as Tools for Manager Coordination
@tool
def do_research(query: str) -> str:
    """Gather raw information on a specific subtopic"""
    result = research_agent.invoke({"messages": [{"role": "user", "content": query}]})
    return result["messages"][-1].content

@tool
def do_analysis(data: str) -> str:
    """Analyze research findings and extract insights"""
    result = analysis_agent.invoke({"messages": [{"role": "user", "content": data}]})
    return result["messages"][-1].content

@tool
def do_writing(data: str) -> str:
    """Format analyzed insights into a finished report"""
    result = writer_agent.invoke({"messages": [{"role": "user", "content": data}]})
    return result["messages"][-1].content

# Step 3: Orchestrate with Manager Agent
manager = create_agent(
    model="google_genai:gemini-2.5-flash",
    system_prompt="""You are a manager coordinating an automated research pipeline.
1. Call do_research with subtopic queries.
2. Pass gathered findings to do_analysis.
3. Pass analyzed insights to do_writing.
Return ONLY the final report output.""",
    tools=[do_research, do_analysis, do_writing]
)