Step 1: Create Specialist Tools
Why multi-agent systems?
A single agent with many tools becomes unreliable as complexity grows. It struggles to choose the right tool from a large set, its prompts become bloated, and errors in one area affect everything.
Multi-agent systems solve this by specialization: each agent handles one type of task with its own focused set of tools.
Single agent (brittle):
Agent → [research, calculate, write, translate, code, search, ...]
Problem: too many tools, confused tool selection
Multi-agent (robust):
Router → Researcher (research tools)
→ Calculator (math tools)
→ Writer (writing tools)
Each agent is an expert at one thing.
What you'll build: a Multi-Agent System
In this lab, you'll build a supervisor/router multi-agent system — the most common multi-agent architecture and a core topic on the NCP-AAI exam (15% Architecture domain).
By the end, your system will have:
- 3 specialist agents — a researcher, a calculator, and a writer, each with their own tools
- An LLM-based router that classifies incoming queries and dispatches to the right specialist
- A LangGraph StateGraph with conditional edges for dynamic routing
- Automated tests validating routing accuracy and answer quality
Test scenarios your finished system handles:
| User asks | Router decides | Specialist handles | Result |
|---|---|---|---|
| "What is NVIDIA NIM?" | → Researcher | Uses research tool | Factual answer |
| "What is 42 * 17?" | → Calculator | Uses calculate tool | "714" |
| "Write a report about RAG" | → Writer | Uses write_report tool | Formatted report |
| "How does LangGraph work?" | → Researcher | Uses research tool | Factual answer |
You'll build this across 6 steps, starting with individual tools and ending with a complete tested multi-agent graph.
Common patterns
| Pattern | Description | When to use |
|---|---|---|
| Supervisor/Router | One agent routes to specialists | Clear task categories |
| Sequential | Agents run in order, output feeds next | Pipeline workflows |
| Hierarchical | Managers delegate to sub-agents | Complex organizations |
| Swarm | Agents self-organize | Exploratory tasks |
This lab builds the supervisor/router pattern — the most common and the one most tested on the NCP-AAI exam.
Starting with tools
Each specialist agent needs its own tools. We'll create three tool sets: research, math, and writing.
Your task
- Import
toolfromlangchain_core.tools - Create a
researchtool (looks up facts from a dict) - Create a
calculatetool (evaluates math expressions) - Create a
write_reporttool (formats a report with topic and content) - Print all tool names and descriptions
NCP-AAI exam note: Multi-agent architecture is the heart of Domain 1 (15%). The exam tests: when to use multi-agent vs single-agent, routing strategies, agent coordination, and failure handling in multi-agent systems. In NAT, this maps to
_type: router_agentand_type: sequential_executor.
agents.py, the file you edit24 lines
# Step 1: Create Specialist Tools
# TODO: Import tool from langchain_core.tools
# TODO: Create a 'research' tool
# - Takes a query (str)
# - Looks up facts from a dict (include facts about: nvidia nim, rag, langgraph, milvus)
# - Returns the fact or "No info found"
# TODO: Create a 'calculate' tool
# - Takes an expression (str)
# - Returns the evaluated result as a string
# TODO: Create a 'write_report' tool
# - Takes topic (str) and content (str)
# - Returns a formatted report string
# Print tool info
tools = [research, calculate, write_report]
for t in tools:
print(f'{t.name}: {t.description}')