Course
Modern AI began with Large Language Models (LLMs), followed by function calling for structured output, then the development of agents and tools, leading to the creation of MCP servers. Currently, the focus is on multi-agent systems. Companies are seeking solutions to build intelligent automated systems using various tools, with AutoGen being the most popular among them.
In this tutorial, we will explore AutoGen, its ecosystem, its various use cases, and how to use each component within that ecosystem. It is important to note that AutoGen is not just a typical language model orchestration tool like LangChain; it offers much more than that.
If you are new to AI, please take the AI Fundamentals skill track before proceeding with this tutorial. You can also learn about Agentic AI in a separate article.
What is AutoGen?
AutoGen is an open-source framework designed for creating multi-agent AI applications that can operate semi-autonomously and fully autonomously. It provides developers with tools to build systems in which multiple AI agents can communicate, cooperate, and perform tasks together.
AutoGen supports a wide range of use cases, including automated workflows, multi-agent collaboration, and dynamic task-solving. It allows developers to create systems where agents can interact through natural language, execute code, retrieve information, and adapt to complex workflows.
The AutoGen ecosystem is divided into four main components:
- AutoGen Studio: A no-code graphical interface for building and testing multi-agent workflows.
- AutoGent AgentChat: A simplified API for building conversational single and multi-agent applications.
- AutoGen Core: The foundational API for building scalable multi-agent AI systems.
- AutoGen Extension: A library of first- and third-party extensions that expand the framework's capabilities.
Source: microsoft/AutoGen
AutoGen stands out for its ability to:
- Simplify the orchestration and optimization of complex LLM workflows.
- Enhance the performance of LLMs while addressing their limitations.
- Enable the seamless creation of multi-agent systems that integrate LLMs, tools, and human inputs.
Its extensibility and modularity make it a powerful tool for developers across industries, from finance and healthcare to education and robotics.
Read Understanding AI Agents: The Future of Autonomous Systems to learn how to leverage AI agents for innovation and efficiency in your projects.
Getting Started With the AutoGen Ecosystem
In this section, we will explore the four main components of the AutoGen ecosystem by installing and running them locally.
1. AutoGen Studio
AutoGen Studio is a low-code interface designed to help you rapidly prototype AI agents. It provides a user-friendly, drag-and-drop interface for creating multi-agent systems and testing them in real time.
1. To install the Studio, use the pip command.
pip install -U AutoGenstudio
2. Once installed, you can launch the AutoGen Studio UI by specifying the port and the application directory where all agents and templates will be stored.
AutoGenstudio ui --port 8080 --appdir ./app
After running the command, you should see the following output in your terminal:
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
2025-05-09 15:15:22.825 | INFO | AutoGenstudio.web.app:lifespan:39 - Application startup complete. Navigate to http://127.0.0.1:8080
3. Navigate to http://127.0.0.1:8080 in your browser to access the AutoGen Studio dashboard.
Once the application is running, you will be greeted with a clean and intuitive user interface.
AutoGen Studio provides several key features to help you build and manage multi-agent workflows:
- Team Builder: A drag-and-drop interface for creating agent teams.
- Playground: An interactive environment for testing and running agent workflows.
- Gallery: A central hub for discovering and importing community-created components.
- Labs: It is an experimental feature in AutoGen Studio that allows users to explore advanced workflows and prototype cutting-edge ideas.
- Deploy: Export and run agent workflows as Python code.
AutoGen Studio is a low-code application, meaning it allows you to build workflows with minimal coding. However, it also provides the flexibility to customize agents and workflows using Python code.
2. AutoGen AgentChat
AgentChat is a high-level framework for creating multi-agent conversational workflows. It simplifies the process of building applications where multiple agents (AI, tools, or humans) collaborate to solve tasks.
First, install the required packages:
pip install -U "AutoGen-agentchat" "AutoGen-ext[openai]"
We will then set up three agents—a user, a coder, and a code executor—that collaborate in a round-robin group chat to generate, execute, and narrate Python code. The system is designed to facilitate dynamic code generation and execution while allowing human interaction and termination conditions.
For this example, we are using the gpt-4.1-mini
model for code generation, CodeExecutorAgent
for command line code execution, and UserProxyAgent
for keeping humans in the loop.
import asyncio
from pathlib import Path
from AutoGen_agentchat.agents import AssistantAgent, CodeExecutorAgent, UserProxyAgent
from AutoGen_agentchat.conditions import TextMentionTermination
from AutoGen_agentchat.teams import RoundRobinGroupChat
from AutoGen_agentchat.ui import Console
from AutoGen_ext.code_executors.local import LocalCommandLineCodeExecutor
from AutoGen_ext.models.openai import OpenAIChatCompletionClient
async def main() -> None:
model_client = OpenAIChatCompletionClient(model="gpt-4.1-mini")
coder = AssistantAgent(
"coder",
model_client=model_client,
system_message=(
"You are a senior engineer. Think step-by-step, then output ONLY runnable "
"Python inside ```pythonthon``` blocks—no commentary."
),
)
executor = CodeExecutorAgent(
"executor",
model_client=model_client, # lets it narrate results
code_executor=LocalCommandLineCodeExecutor(work_dir=Path.cwd() / "runs"),
)
user = UserProxyAgent("user") # human in the loop
termination = TextMentionTermination("exit", sources=["user"])
team = RoundRobinGroupChat(
[user, coder, executor], termination_condition=termination
)
try:
await Console(
team.run_stream()
)
finally:
await model_client.close()
if __name__ == "__main__":
asyncio.run(main())
Save the above code in a file chat_app.py
, and run it using:
python chat_app.py
We have requested the Agent application to generate code for printing the stars in a triangle shape, and then execute the code.
It successfully generated the code and executed it, while also offering additional options. The user can type “exit” to quit or ask follow-up questions for a conversational experience.
Output:
Enter your response: Write a Python script that prints stars and run it.
---------- TextMessage (user) ----------
Write a Python script that prints stars and run it.
---------- TextMessage (coder) ----------
# Print a simple star pattern
for i in range(1, 6):
print('*' * i)
---------- CodeGenerationEvent (executor) ----------
# Print a simple star pattern
for i in range(1, 6):
print('*' * i)
---------- CodeExecutionEvent (executor) ----------
*
**
***
****
*****
---------- TextMessage (executor) ----------
The star pattern has been printed successfully. If you'd like a different pattern or further modifications, just let me know!
Enter your response:
3. AutoGen Core
The AutoGen Core is a low-level framework that provides a powerful way to create and manage multi-agent systems.
In this example, we will create two agents: an Echo Agent that reverses the content of a message and a Printer Agent that prints the message content to the console.
pip install "autogen-core"
Components used in this application:
- Message structure: The
Text
class is a simple data structure that holds the content of a message.
- Echo Agent: The
Echo
agent reverses the content of any message it receives and publishes the reversed message to the default topic usingpublish_message
.
- Printer Agent: The
Printer
agent listens for messages and prints their content to the console.
- Runtime: The
SingleThreadedAgentRuntime
is used to manage the lifecycle of the agents and handle message routing.
import asyncio
from dataclasses import dataclass
from AutoGen_core import (
AgentId,
DefaultTopicId,
MessageContext,
RoutedAgent,
SingleThreadedAgentRuntime,
default_subscription,
message_handler,
)
@dataclass
class Text:
content: str
@default_subscription
class Echo(RoutedAgent):
def __init__(self) -> None:
super().__init__("echo")
@message_handler
async def handle(self, message: Text, ctx: MessageContext) -> None: # param must be named 'message'
await self.publish_message(Text(message.content[::-1]), DefaultTopicId())
@default_subscription
class Printer(RoutedAgent):
def __init__(self) -> None:
super().__init__("printer")
@message_handler
async def handle(self, message: Text, ctx: MessageContext) -> None: # param must be named 'message'
print(message.content)
async def main() -> None:
rt = SingleThreadedAgentRuntime()
await Echo.register(rt, "echo", lambda: Echo())
await Printer.register(rt, "printer", lambda: Printer())
rt.start()
await rt.send_message(Text("DataCamp"), AgentId("echo", "default"))
await rt.stop_when_idle()
if __name__ == "__main__":
asyncio.run(main())
Save the code in a file core_app.py
, and run it using:
python core_app.py
Message Flow:
- A message with the content "DataCamp" is sent to the Echo agent.
- The Echo agent reverses the message to "pmaCataD" and publishes it.
- The Printer agent receives the reversed message and prints it to the console.
Output:
pmaCataD
4. AutoGen Extensions
The AutoGen Extensions framework provides first- and third-party extensions that expand the framework's capabilities.
In this example, we will demonstrate how to use the MultimodalWebSurfer
agent, which can interact with web pages, perform searches, and extract information.
Before running the example, ensure you have Playwright
installed:
playwright install
How the code works:
- Agent initialization: A
MultimodalWebSurfer
agent is created, which uses OpenAI'sgpt-4.1-mini
model for decision-making and a browser (via Playwright) for web interactions. - Team setup: The agent is added to a
RoundRobinGroupChat
team, which manages the agent's workflow and limits the task to 3 turns. - Task execution: The team is instructed to perform the task: "Navigate to Google and search about Abid Ali Awan." The agent opens a browser, navigates to Google, performs the search, and extracts relevant information.
- Streaming output: The agent's actions (e.g., navigating to a page, clicking links, extracting metadata) are streamed to the console in real time.
- Cleanup: After the task is completed, the browser is closed to release resources.
import asyncio
from AutoGen_agentchat.ui import Console
from AutoGen_agentchat.teams import RoundRobinGroupChat
from AutoGen_ext.models.openai import OpenAIChatCompletionClient
from AutoGen_ext.agents.web_surfer import MultimodalWebSurfer
async def main() -> None:
# Define an agent
web_surfer_agent = MultimodalWebSurfer(
name="MultimodalWebSurfer",
model_client=OpenAIChatCompletionClient(model="gpt-4.1-mini"),
)
# Define a team
agent_team = RoundRobinGroupChat([web_surfer_agent], max_turns=3)
# Run the team and stream messages to the console
stream = agent_team.run_stream(task="Navigate to Google and search about Abid Ali Awan.")
await Console(stream)
# Close the browser controlled by the agent
await web_surfer_agent.close()
asyncio.run(main())
Save the code in a file, web_ext_app.py
, and run it using:
python web_ext_app.py
When you run the application, the following interaction will occur:
---------- TextMessage (user) ----------
Navigate to Google and search about Abid Ali Awan.
---------- MultiModalMessage (MultimodalWebSurfer) ----------
I typed 'https://www.google.com' into the browser address bar.
The web browser is open to the page [Google](https://www.google.com/).
The viewport shows 100% of the webpage, and is positioned at the top of the page
The following text is visible in the viewport:
Gmail
Images
Sign in
Google offered in:
اردو
پښتو
سنڌيPakistan
About
Advertising
Business
How Search works
Privacy
Terms
Settings
Google recommends using Chrome
Try a fast, secure browser with updates built in
Don't switch
Yes
The following metadata was extracted from the webpage:
{
"microdata": [
{
"itemType": "http://schema.org/WebPage",
"image": "/images/branding/googleg/1x/googleg_standard_color_128dp.png"
}
],
"meta_tags": {
"referrer": "origin"
}
}
Here is a screenshot of the page.
<image>
---------- MultiModalMessage (MultimodalWebSurfer) ----------
I clicked 'Sign in'.
The web browser is open to the page [Sign in - Google Accounts](https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fwww.google.com%2F&ec=futura_exp_og_so_72776762_e&hl=en&ifkv=ASKV5MhAzFZnwDH-Aw10tuqQN1ppsY8OZ2-OJ3YavFHXMDlX9iTddg1d_k78ZZ0SogFUivcY7Td0Hg&passive=true&flowName=GlifWebSignIn&flowEntry=ServiceLogin&dsh=S1980923188%3A1746809726624486).
The viewport shows 100% of the webpage, and is positioned at the top of the page
The following text is visible in the viewport:
Sign inUse your Google AccountEmail or phone
Forgot email?
Not your computer? Use a private browsing window to sign in.
Learn more about using Guest modeNext
Create account
English (United States)
Help
Privacy
Terms
Sign in Use your Google Account
The following metadata was extracted from the webpage:
{
"meta_tags": {
"referrer": "origin",
"chrome": "nointentdetection",
"viewport": "width=device-width, initial-scale=1",
"description": ""
}
}
Here is a screenshot of the page.
<image>
---------- TextMessage (MultimodalWebSurfer) ----------
Please provide the email or phone number you want to use to sign in, or let me know if you want to create a new account or need help with something else on this page.
Similar to AutoGen, CrewAI is another AI fan-favorite framework for building agentic workflows. Follow the CrewAI: A Guide With Examples of Multi AI Agent Systems tutorial to learn more about it.
AutoGen Use Cases
AutoGen opens up numerous possibilities for creating intelligent, multi-agent systems. Here are some of the most prominent use cases of the AutoGen ecosystem:
- Code generation, execution, and debugging: Automates coding tasks, reducing errors and improving efficiency.
- Multi-agent collaboration: Enables teamwork among agents to solve complex tasks.
- Sequential multi-agent chats: Manages structured task sequences for efficient completion.
- Nested chats: Handles intricate tasks through detailed, layered conversations.
- Tool use: Expands agent functionality by integrating tools like web search and SQL queries.
- Human involvement: Incorporates human feedback to improve workflows.
- Agent teaching and learning: Enhances agent skills and knowledge.
- Multi-agent chat with OpenAI Assistants: Combines OpenAI capabilities with AutoGen for advanced tasks.
- Multimodal Agent: Handles text, images, and other media for richer interactions.
- Long context handling: Maintains coherence in extended conversations.
Conclusion
There is a reason why AutoGen has gained so much attention and recognition, earning its place as one of the most starred Agentic frameworks on GitHub.
It is a comprehensive framework that caters to everyone, from professional developers to casual programmers, and even individuals with no prior coding experience.
With AutoGen, you can rapidly prototype workflows using AutoGen Studio, build robust applications with the Core framework and Extensions, and seamlessly deploy them to the cloud. It truly is an all-in-one solution for creating and managing intelligent multi-agent systems.
Take the Build Dynamic LangChain Agents course and learn to build your first AI agent application using the popular LLM framework.
Multi-Agent Systems with LangGraph

As a certified data scientist, I am passionate about leveraging cutting-edge technology to create innovative machine learning applications. With a strong background in speech recognition, data analysis and reporting, MLOps, conversational AI, and NLP, I have honed my skills in developing intelligent systems that can make a real impact. In addition to my technical expertise, I am also a skilled communicator with a talent for distilling complex concepts into clear and concise language. As a result, I have become a sought-after blogger on data science, sharing my insights and experiences with a growing community of fellow data professionals. Currently, I am focusing on content creation and editing, working with large language models to develop powerful and engaging content that can help businesses and individuals alike make the most of their data.