Why Multi-Agent Systems?
Complex problems often require multiple specialized agents working together:- Code generation: Architect designs, Developer implements, Reviewer validates
- Research: Searcher finds sources, Analyst synthesizes, Writer drafts
- Customer support: Classifier routes, Specialist handles, QA verifies
Coordination Architecture
Coordinator Trait
All coordination patterns implement theCoordinator trait:
mofa-kernel/src/agent/components/coordinator.rs
Coordination Patterns
- Sequential
- Parallel
- Hierarchical
- Consensus
- Debate
- MapReduce
- Voting
Sequential Execution: Output of one agent becomes input to the next.Use Cases:
- Data pipelines (fetch → process → store)
- Multi-step reasoning (plan → execute → verify)
- Content generation (research → draft → edit)
Task Definition
Tasks are the units of work passed to coordinators:| Field | Type | Description |
|---|---|---|
id | String | Unique task identifier |
task_type | TaskType | Category (Analysis, Generation, etc.) |
content | String | Task description/prompt |
priority | TaskPriority | Execution priority (Low, Normal, High, Urgent) |
target_agent | Option<String> | Specific agent to use (optional) |
params | HashMap | Additional parameters |
timeout_ms | Option<u64> | Maximum execution time |
Aggregation Strategies
How to combine results from multiple agents:- Concatenate
- FirstSuccess
- CollectAll
- Vote
- LLM Summarize
Join all outputs with a separator:Result:
"Output 1\n\nOutput 2\n\nOutput 3"Communication Patterns
Message Bus
Agents communicate via the microkernel message bus:Agent Discovery
Find agents by capabilities:Priority Scheduling
Tasks are executed based on priority:- Higher priority tasks preempt lower priority
- Same priority uses FIFO queue
- Urgent tasks interrupt running tasks (if interruptible)
Secretary Agent Pattern
MoFA includes a specialized Secretary Agent for human-in-the-loop workflows: Features:- 🧠 Autonomous task planning and decomposition
- 🔄 Intelligent agent scheduling
- 👤 Human intervention at key nodes
- 📊 Full process observability
- 🔁 Closed-loop feedback
Secretary Agent Guide
Learn how to build human-in-the-loop workflows
Real-World Example
Scenario: Code review systemPerformance Considerations
Next Steps
Workflow Engine
Build complex stateful workflows
Examples
See coordination patterns in action