Coordinator Agent
Multi-agent orchestrator with specialized sub-agents.
Difficulty: Expert
What You'll Learn
- Multi-agent orchestration
- Sub-agent invocation control
- State sharing between agents
- Nested audit trails
Architecture
┌─────────────┐
│ Coordinator │
└──────┬──────┘
┌───────────────┼───────────────┐
▼ ▼ ▼
┌────────────┐ ┌────────────┐ ┌────────────┐
│ Researcher │ │ Writer │ │ Reviewer │
└────────────┘ └────────────┘ └────────────┘
│
▼
┌────────────┐
│ Wikipedia │
└────────────┘
Sub-Agents
| Agent | Role | HTTP Access |
|---|---|---|
| Researcher | Gathers facts | Wikipedia |
| Writer | Creates content | Ollama only |
| Reviewer | Reviews quality | Ollama only |
Workflow
- Plan: Extract topic from request
- Research: Gather facts via Wikipedia
- Write: Create content from research
- Review: Quality feedback
- Finalize: Compile output
Setup
agentvisor template create langgraph/coordinator-agent
cd coordinator-agent
docker compose up -d
agentvisor serve .
Test It
THREAD=$(curl -sX POST http://localhost:8090/threads | jq -r '.thread_id')
# Request content (allow 120s for all sub-agents)
curl -sX POST "http://localhost:8090/threads/$THREAD/runs?wait=120s" \
-H "Content-Type: application/json" \
-d '{"input": {"messages": [{"role": "user", "content": "Write an article about quantum computing"}]}}'
Expected Output
# Content Creation Complete
## Topic: Quantum Computing
---
## Content
[Written content...]
---
## Review
[Reviewer feedback...]
---
*Created by Coordinator Agent*
Key Code
Sub-Agent Module
# agents/researcher.py
def research(topic: str) -> str:
wiki_data = search_wikipedia(topic)
llm = ChatOllama(...)
response = llm.invoke([
SystemMessage(content=SYSTEM_PROMPT),
HumanMessage(content=f"Research: {topic}\n\n{wiki_data}")
])
return response.content
Coordinator Graph
builder = StateGraph(CoordinatorState)
builder.add_node("plan", plan)
builder.add_node("research", do_research)
builder.add_node("write", do_write)
builder.add_node("review", do_review)
builder.add_node("finalize", finalize)
builder.set_entry_point("plan")
builder.add_edge("plan", "research")
builder.add_edge("research", "write")
builder.add_edge("write", "review")
builder.add_edge("review", "finalize")
builder.add_edge("finalize", END)
Policy Highlights
Sub-Agent Allowlist
annotations:
- name: "allowed_subagents"
value:
- "researcher"
- "writer"
- "reviewer"
HTTP per Sub-Agent
# Researcher needs Wikipedia, others only Ollama
annotations:
- name: "allowed_patterns"
value:
- "^ollama.*"
- "^en\\.wikipedia\\.org(/.*)?$"
Performance Notes
- Each sub-agent makes LLM calls
- Research also makes HTTP call
- Expect 60-120 seconds total
- Use
?wait=120stimeout
Extending
To add a new sub-agent:
- Create
agents/new_agent.py - Export from
agents/__init__.py - Add node in coordinator
- Update policy allowlist