Before diving into the lab, please read through the BASICS.md file to understand key concepts about multi-agent systems, architectures, and communication patterns. This foundational knowledge will help you grasp the implementations in this lab.
This lab introduces multi-agent systems - where multiple AI agents collaborate to solve complex problems. You'll work with two popular frameworks (AutoGen and CrewAI) to build, compare, and understand how intelligent agents can work together.
- How to design agents with specific roles and responsibilities
- How agents communicate and collaborate
- Differences between conversational (AutoGen) vs. task-based (CrewAI) approaches
- When to use each framework for different problem types
Scenario: Build a product plan for an AI-powered interview platform
Four agents collaborate in a GroupChat (LLM selects who speaks next):
- ResearchAgent - Analyzes market competitors
- AnalysisAgent - Identifies key opportunities
- BlueprintAgent - Creates product design
- ReviewerAgent - Provides recommendations
Communication Style: Conversational GroupChat (agents converse freely, reference each other's contributions, LLM-based speaker selection)
Scenario: Plan a 5-day trip to Iceland
Four agents form a "crew":
- FlightAgent - Researches flights
- HotelAgent - Finds accommodations
- ItineraryAgent - Creates daily plans
- BudgetAgent - Calculates costs
Communication Style: Task-based (each agent completes assigned tasks)
- Framework for building multi-agent systems with LLMs
- Agents converse in a GroupChat managed by a GroupChatManager
- LLM-based speaker selection β the model decides who speaks next
- Great for iterative, conversational problem solving
from autogen import AssistantAgent, UserProxyAgent, GroupChat, GroupChatManager
# Create specialized agents
researcher = AssistantAgent(name="Researcher", system_message="...", llm_config=llm_config)
analyst = AssistantAgent(name="Analyst", system_message="...", llm_config=llm_config)
user_proxy = UserProxyAgent(name="Admin", human_input_mode="NEVER", code_execution_config=False)
# Assemble into a group chat
groupchat = GroupChat(agents=[user_proxy, researcher, analyst], messages=[], max_round=12)
manager = GroupChatManager(groupchat=groupchat, llm_config=llm_config)
# Start the multi-agent conversation
user_proxy.initiate_chat(manager, message="Your task here")- High-level framework for orchestrating agent "crews"
- Task-based execution - clear inputs and outputs
- Built-in tools and structured workflows
- Great for sequential, goal-oriented tasks
from crewai import Agent, Task, Crew
agent = Agent(role="...", goal="...", backstory="...")
task = Task(description="...", agent=agent)
crew = Crew(agents=[agent], tasks=[task])
result = crew.kickoff()- Powers the language models both frameworks use
- GPT-4 or GPT-4-Turbo for intelligent reasoning
- Python 3.8+
- OpenAI API key (get from https://platform.openai.com/api-keys)
pippackage manager
1. Configure API Key:
# Copy template
cp .env.example .env
# Add your OpenAI API key
# Edit .env and add:
OPENAI_API_KEY=sk-your-api-key-here2. Install Dependencies:
pip install -r requirements.txt3. Verify Configuration:
python shared_config.pyAutoGen Demo:
python autogen/autogen_simple_demo.pyCrewAI Demo:
python crewai/crewai_demo.pymulti-agent/
βββ README.md β You are here (complete lab guide)
βββ requirements.txt β Install ALL dependencies from here
βββ .env.example β Copy to .env (don't commit!)
βββ .env β Your configuration (add API key here)
βββ shared_config.py β Unified config for both frameworks
β
βββ autogen/
β βββ config.py β AutoGen configuration (uses shared_config)
β βββ autogen_simple_demo.py β RUN THIS: GroupChat demo
β
βββ crewai/
βββ crewai_demo.py β RUN THIS: Travel planning demo
# Create .env file with your API key
cp .env.example .env
nano .env # Add your OPENAI_API_KEYpip install -r requirements.txtpython shared_config.py
# Should show: β
Configuration validation passed!# Try AutoGen
python autogen/autogen_simple_demo.py
# OR try CrewAI
python crewai/crewai_demo.pyAgent: An AI entity with a specific role, goal, and reasoning ability
Agent(
role="Flight Specialist",
goal="Find the best flights for the trip",
backstory="You have booked thousands of flights..."
)Task: Work to be completed by an agent
Task(
description="Research flights from NYC to Reykjavik",
agent=flight_agent,
expected_output="List of flight options with prices"
)Workflow: How agents interact and pass information
- GroupChat (AutoGen): Agents converse in a shared chat room, LLM picks the next speaker each turn
- Sequential (CrewAI): Each agent completes an assigned task, output passes to next agent
- Parallel: Multiple agents work simultaneously (advanced)
- Specialization: Each agent is expert in one area
- Modularity: Easy to add/remove agents
- Scalability: Handle complex problems by breaking them down
- Transparency: Understand reasoning at each step
| Aspect | AutoGen | CrewAI |
|---|---|---|
| Communication | Conversational GroupChat | Task-based |
| Workflow | Emergent, LLM-orchestrated | Structured, sequential |
| Orchestration | GroupChatManager selects speakers | Crew executes tasks in order |
| Setup | More code, more control | Less code, simpler |
| Best For | Iterative, collaborative problem-solving | Clear, goal-oriented workflows |
| Agent Autonomy | High (agents converse freely) | Lower (follows task structure) |
| Output Structure | Unstructured conversation | Structured task outputs |
| Learning Curve | Steeper | Gentler |
- β Problem requires iteration, debate, and refinement
- β Agents need to converse and build on each other's ideas
- β Speaker order should emerge dynamically (LLM-selected)
- β You need fine-grained control over agent interactions
- β Workflow is well-defined and sequential
- β Each agent has clear inputs/outputs
- β You want faster setup with less code
- β Tasks are independent and composable
- Run
autogen/autogen_simple_demo.py - Read the output - understand how agents interact
- Run
crewai/crewai_demo.py - Compare the communication styles
The goal is to observe how changing an agent's persona affects the group conversation (AutoGen) or task output (CrewAI).
AutoGen: Edit autogen/autogen_simple_demo.py β modify the ResearchAgent's system_message:
# Find this in _create_agents() and change the focus area:
self.research_agent = autogen.AssistantAgent(
name="ResearchAgent",
system_message="""You are a market research analyst specializing in...
# β Try changing the focus: instead of AI interview platforms,
# focus on "AI-powered employee onboarding tools"
# or change the competitors to research (Deel, Rippling, BambooHR)
""",
...
)Run the demo again β observe how downstream agents (AnalysisAgent, BlueprintAgent) adapt their responses to the new research context without any changes to their own prompts.
CrewAI: Edit crewai/crewai_demo.py β modify the create_flight_agent() function:
return Agent(
role="Flight Specialist",
goal=f"...",
backstory="You are an experienced flight specialist..."
# β Try adding constraints to the backstory:
# "You always prioritize direct flights over connections."
# "You focus on budget airlines and cost savings above all."
# Then observe how the flight recommendations change.
)Questions to answer:
- How does one agent's changed behavior ripple through to other agents?
- In AutoGen, did the GroupChatManager still select speakers in the same order?
- In CrewAI, did the budget agent's calculations reflect the flight agent's new priorities?
Add a new specialist to each framework and observe how it changes the group dynamic.
AutoGen β Add a CostAnalyst agent to the GroupChat in autogen/autogen_simple_demo.py:
- Create the agent in
_create_agents():
self.cost_agent = autogen.AssistantAgent(
name="CostAnalyst",
system_message="""You are a financial analyst. After the BlueprintAgent presents features,
estimate development costs and timeline for each feature. Provide a cost-benefit ranking.
After your analysis, invite the ReviewerAgent to provide final recommendations.
Keep your response under 400 words.""",
llm_config=self.llm_config,
description="Financial analyst who estimates development costs and ROI for proposed features.",
)-
Add it to the
agentslist in_setup_groupchat()(between BlueprintAgent and ReviewerAgent) -
Increase
max_roundfrom 8 to 10 -
Run and observe: Does the GroupChatManager select the CostAnalyst at the right time? Does the ReviewerAgent incorporate cost data into its recommendations?
CrewAI β Add a LocalExpert agent and task in crewai/crewai_demo.py:
- Create a new agent function that knows local customs, tips, and safety info
- Create a corresponding
Taskwith a specificexpected_output - Add both to the
Crewβ place the task between itinerary and budget - Run and observe: Does the budget agent account for the local expert's tips?
Rewrite one of the demos for a completely different domain. Pick one:
- Conference planning (speakers, venues, schedule, sponsorship)
- Software architecture (requirements, design, implementation plan, risk assessment)
- Marketing campaign (audience research, messaging, channels, budget)
Steps:
- Keep the same framework structure (GroupChat for AutoGen, Crew for CrewAI)
- Change agent roles, system messages, and the initial prompt
- Run both frameworks on the same problem
- Compare: Which framework produced a more useful result for your chosen domain? Why?
# Make sure .env file exists and has your key
cat .env
# If missing, create it:
cp .env.example .env
# Then edit and add your key
nano .env# Run from project root, not from subdirectories
cd /Users/pranavhharish/Desktop/IS-492/multi-agent
python crewai/crewai_demo.py# Check your key is valid at:
# https://platform.openai.com/account/api-keys
# Make sure it's in .env without quotes:
OPENAI_API_KEY=sk-proj-xxxxx # β Correct
# OPENAI_API_KEY="sk-proj-xxxxx" # β Wrong (don't use quotes)- Wait a few minutes and try again
- Check your API usage: https://platform.openai.com/account/usage
- AutoGen Docs - Official AutoGen documentation
- CrewAI Docs - Official CrewAI documentation
- OpenAI API - API reference and guides
- LLM Agent Systems - Deep dive into agent theory
- ReAct Prompting - How agents think and act
- Multi-Agent Collaboration - Research on agent cooperation
- AutoGen: GitHub discussions at microsoft/autogen
- CrewAI: GitHub issues at joaomdmoura/crewai