How the Project Manager agent orchestrates multi-agent workflows.
The PM (Project Manager) agent is the orchestrator in Claude MPM's multi-agent system. It analyzes user requests, breaks them into subtasks, and delegates to specialist agents.
PM Responsibilities:
- Task Analysis: Understand user intent and requirements
- Planning: Break complex tasks into manageable subtasks
- Delegation: Route subtasks to appropriate specialist agents
- Coordination: Manage dependencies between subtasks
- Integration: Combine results from multiple agents
- Quality: Ensure deliverables meet requirements
PM receives user request and analyzes:
- Intent: What user wants to accomplish
- Complexity: Single-agent vs multi-agent task
- Requirements: Technical requirements and constraints
- Dependencies: Task dependencies and order
PM creates execution plan:
- Decomposition: Break into subtasks
- Sequencing: Determine execution order
- Agent Selection: Match subtasks to specialist capabilities
- Context Preparation: Prepare context for each agent
PM delegates subtasks:
PM: "I need to implement authentication for the API."
↓
Research Phase:
PM → Research Agent: "Analyze current auth implementation"
↓
Implementation Phase:
PM → Engineer Agent: "Implement JWT-based authentication"
↓
Testing Phase:
PM → QA Agent: "Create test suite for authentication"
↓
Documentation Phase:
PM → Documentation Agent: "Update API docs with auth endpoints"
PM manages execution:
- Sequential Tasks: Wait for dependencies
- Parallel Tasks: Execute independently
- Error Handling: Retry or reassign on failure
- Progress Tracking: Monitor completion
PM combines results:
- Result Aggregation: Collect outputs from all agents
- Quality Check: Verify deliverables
- Consolidation: Create unified response
- Memory Update: Store learnings
PM routes tasks based on agent capabilities and specialization.
Research Agent (research):
- Codebase analysis
- Documentation review
- Architecture understanding
- Pattern identification
Engineer Agent (engineer):
- Feature implementation
- Code refactoring
- Bug fixes
- Technical design
QA Agent (qa):
- Test creation
- Quality validation
- Bug verification
- Test coverage analysis
Documentation Agent (documentation):
- API documentation
- User guides
- Code comments
- README updates
# Simplified routing logic
def route_task(task: str) -> str:
if "analyze" in task or "understand" in task:
return "research"
elif "implement" in task or "create" in task:
return "engineer"
elif "test" in task or "validate" in task:
return "qa"
elif "document" in task:
return "documentation"
else:
return "pm" # PM handles unclear tasksComplex tasks require multiple agents:
Example: "Add feature X"
- Research Agent: Analyze codebase for integration points
- Engineer Agent: Implement feature
- QA Agent: Create tests
- Documentation Agent: Update docs
Example: "Fix bug Y"
- Research Agent: Reproduce and analyze bug
- Engineer Agent: Implement fix
- QA Agent: Verify fix and add regression test
Tasks with dependencies execute sequentially:
Request: "Refactor module X and update tests"
↓
Research: Analyze current structure
↓
Engineer: Refactor module (depends on research)
↓
QA: Update tests (depends on refactoring)
Independent tasks execute in parallel:
Request: "Document API endpoints and create examples"
↓
├─→ Documentation: API reference
└─→ Engineer: Example implementations
Tasks requiring multiple passes:
Request: "Optimize performance"
↓
Research: Identify bottlenecks
↓
Engineer: Implement optimization
↓
QA: Measure performance
↓
Research: Analyze new metrics (if needed)
↓
[Repeat until performance goal met]
Handling agent failures:
Task fails
↓
PM analyzes failure
↓
├─→ Retry with same agent (transient error)
├─→ Reassign to different agent (capability mismatch)
└─→ Break into smaller subtasks (too complex)
Clear Delegation:
- Provide specific, actionable instructions
- Include necessary context
- Specify success criteria
- Set realistic expectations
Effective Coordination:
- Identify dependencies early
- Parallelize when possible
- Monitor progress actively
- Adjust plan when needed
Quality Focus:
- Verify deliverables meet requirements
- Ensure consistency across agents
- Validate integrations work
- Request improvements if needed
Accept Delegation:
- Acknowledge task clearly
- Request clarification if needed
- Report progress to PM
- Return to PM when complete
Stay Focused:
- Work within assigned scope
- Don't expand scope without PM approval
- Delegate back to PM for out-of-scope work
- Complete assigned task before moving on
Communicate:
- Report blockers immediately
- Share important findings
- Update PM on progress
- Request help when stuck
Clear Requests:
- Be specific about what you want
- Provide context
- Specify constraints
- Indicate priority
Trust PM:
- Let PM handle delegation
- Don't micromanage agent selection
- Allow PM to adjust plan
- Review final results, not intermediate steps
Provide Feedback:
- Clarify when PM misunderstands
- Adjust requirements if needed
- Validate final deliverables
- Store learnings for future tasks
Next Steps:
- Agent Patterns: See agent-patterns.md
- Creating Agents: See creating-agents.md
- User Guide: See ../user/user-guide.md