====== Multi-Agent Systems ====== **Multi-agent systems** (MAS) organize multiple specialized AI agents — typically powered by large language models — to collaborate on complex tasks through structured coordination patterns. By 2025, multi-agent architectures have become the dominant approach for building sophisticated AI applications, outperforming single-agent systems in parallel processing, adaptability, and collective reasoning. ===== Orchestrator Patterns ===== ==== Supervisor (Central Orchestrator) ==== A primary agent acts as a hub, decomposing tasks, routing them to specialized workers, and synthesizing results. This hub-and-spoke model ensures consistency and simple debugging, but can bottleneck at 10-20 agents due to coordination overhead and context concentration. Variants include the **Single Agent + Dynamic Routing** pattern, where the primary agent invokes specialists via dynamic function calling based on the current task. ==== Peer-to-Peer ==== Agents collaborate directly without a central authority, enabling flexible local optimizations like negotiation. For example, driver agents might share route information in a delivery system. Peer-to-peer supports emergent behaviors but risks inconsistency without oversight. ==== Hierarchical ==== A multi-level structure with supervisor agents at the top, domain agents in the middle, and specialists at the bottom. Combines parallel execution, feedback loops, and shared tools/RAG for knowledge access. The control flow follows: decompose, execute parallel subtasks, gather feedback/refine, aggregate results. ^ Pattern ^ Strengths ^ Weaknesses ^ Best For ^ | Supervisor | Guaranteed consistency, simple debugging | Orchestrator bottleneck, sequential latency | Task routing, research pipelines | | Peer-to-Peer | Tactical flexibility, high throughput | Potential inconsistency | Local optimizations, negotiations | | Hierarchical | Scalable, parallel processing | Complex state management | Multi-domain problems, content creation | | Hybrid | Strategic + tactical balance | Implementation complexity | Enterprise workflows | ===== Debate and Voting ===== Agents can engage in **debate** by proposing solutions, critiquing peers, and iterating via feedback loops. A **voting** mechanism selects the best output from multiple candidates. This pattern improves reasoning through diverse perspectives and is often implemented as: * Multiple agents independently propose solutions * A critic agent evaluates and scores proposals * Agents revise based on feedback * Final selection via majority vote or weighted scoring The **Mixture of Agents** approach uses diverse specialist agents to achieve collective intelligence that exceeds any individual agent's capability. ===== Agent Specialization ===== Role-specialized agents (researcher, writer, coder, reviewer) leverage domain expertise while using smaller, more efficient models. Key enablers include: * **Shared Tools/RAG**: Centralized access to web search, code execution, and knowledge stores * **State Management**: Protocols for context sharing, failure handling, and inter-agent messaging * **Human-in-the-Loop**: Oversight for critical decisions and quality assurance * **Memory Systems**: Shared and individual memory for context retention ===== Code Example ===== # Supervisor pattern using LangGraph from langgraph.graph import StateGraph, END from typing import TypedDict, Literal class TeamState(TypedDict): task: str research: str code: str review: str status: str def supervisor(state: TeamState) -> TeamState: """Supervisor decomposes task and routes to specialists.""" if not state.get('research'): return {**state, 'status': 'needs_research'} elif not state.get('code'): return {**state, 'status': 'needs_coding'} elif not state.get('review'): return {**state, 'status': 'needs_review'} return {**state, 'status': 'complete'} def researcher(state: TeamState) -> TeamState: result = llm.invoke(f"Research: {state['task']}") return {**state, 'research': result} def coder(state: TeamState) -> TeamState: result = llm.invoke(f"Code solution based on: {state['research']}") return {**state, 'code': result} def reviewer(state: TeamState) -> TeamState: result = llm.invoke(f"Review code: {state['code']}") return {**state, 'review': result} def route(state: TeamState) -> Literal['researcher', 'coder', 'reviewer', '__end__']: status = state['status'] if status == 'needs_research': return 'researcher' if status == 'needs_coding': return 'coder' if status == 'needs_review': return 'reviewer' return '__end__' graph = StateGraph(TeamState) graph.add_node('supervisor', supervisor) graph.add_node('researcher', researcher) graph.add_node('coder', coder) graph.add_node('reviewer', reviewer) graph.set_entry_point('supervisor') graph.add_conditional_edges('supervisor', route) for node in ['researcher', 'coder', 'reviewer']: graph.add_edge(node, 'supervisor') app = graph.compile() ===== Frameworks Implementing MAS ===== * **[[crewai]]** — Role-based crews with sequential/hierarchical processes * **[[autogen]]** — Conversational multi-agent systems with group chat * **[[langgraph]]** — Graph-based stateful agent orchestration with cycles * **[[openai_agents_sdk]]** — Lightweight multi-agent handoffs * **[[smolagents]]** — Code-first lightweight agents with sub-agent support ===== Design Principles ===== * **Agents 1.0 vs. 2.0**: Version 1.0 uses rigid, predetermined workflows; version 2.0 enables adaptive collaboration and emergent behaviors * **Loop Mechanisms**: Iterative refinement cycles within hierarchies improve output quality * **Parallel Execution**: Multiple agents processing subtasks simultaneously boosts throughput * **Failure Recovery**: Robust error handling and fallback routing prevent cascading failures ===== References ===== * [[https://www.anthropic.com/engineering/multi-agent-research-system|Anthropic — Multi-Agent Research System]] * [[https://galileo.ai/blog/architectures-for-multi-agent-systems|Architectures for Multi-Agent Systems]] * [[https://dev.to/sohail-akbar/the-ultimate-guide-to-ai-agent-architectures-in-2025-2j1c|Ultimate Guide to AI Agent Architectures 2025]] * [[https://www.infoq.com/news/2026/01/multi-agent-design-patterns/|Multi-Agent Design Patterns (2026)]] ===== See Also ===== * [[crewai]] — CrewAI multi-agent framework * [[autogen]] — Microsoft AutoGen/AG2 * [[langgraph]] — LangGraph stateful agent graphs * [[a2a_protocol]] — Agent-to-Agent communication protocol * [[agent_evaluation]] — Benchmarks for evaluating agents