autogen
**Multi-Agent Frameworks**
**Why Multi-Agent?**
Single agents struggle with complex tasks. Multi-agent systems break problems down by having specialized agents collaborate, each with distinct roles and capabilities.
**Microsoft AutoGen**
**Overview**
Framework for building multi-agent conversational systems with flexible agent orchestration.
**Key Concepts**
| Concept | Description |
|---------|-------------|
| ConversableAgent | Base agent that can send/receive messages |
| AssistantAgent | LLM-powered agent for reasoning |
| UserProxyAgent | Represents human, can execute code |
| GroupChat | Manages multi-agent conversations |
**Example**
```python
from autogen import AssistantAgent, UserProxyAgent
# Create agents
assistant = AssistantAgent(
name="assistant",
llm_config={"model": "gpt-4o"}
)
user_proxy = UserProxyAgent(
name="user_proxy",
code_execution_config={"work_dir": "coding"}
)
# Start conversation
user_proxy.initiate_chat(assistant, message="Analyze sales data")
```
**CrewAI**
**Overview**
Framework for orchestrating role-playing AI agents working together as a "crew" on complex tasks.
**Key Components**
| Component | Description |
|-----------|-------------|
| Agent | Entity with role, goal, backstory |
| Task | Specific work item for an agent |
| Crew | Group of agents + their tasks |
| Tools | Capabilities agents can use |
**Example**
```python
from crewai import Agent, Task, Crew
researcher = Agent(
role="Research Analyst",
goal="Find accurate information",
backstory="Expert researcher with attention to detail"
)
writer = Agent(
role="Content Writer",
goal="Create engaging content",
backstory="Experienced writer"
)
research_task = Task(description="Research AI trends", agent=researcher)
writing_task = Task(description="Write article based on research", agent=writer)
crew = Crew(agents=[researcher, writer], tasks=[research_task, writing_task])
result = crew.kickoff()
```
**Comparison**
| Feature | AutoGen | CrewAI |
|---------|---------|--------|
| Agent style | Conversational | Role-playing |
| Orchestration | Flexible | Sequential/hierarchical |
| Code execution | Built-in | Via tools |
| Use case | General | Creative workflows |
**Multi-Agent Patterns**
- **Hierarchical**: Manager delegates to workers
- **Sequential**: Agents work in order
- **Collaborative**: Agents discuss and iterate
- **Competitive**: Agents propose, vote on solutions