This page contains a collection of notebooks that demonstrate how to use AG2. The notebooks are tagged with the topics they cover. For example, a notebook that demonstrates how to use function calling will be tagged with tool/function.
Using Guidance with AG2
Using Guidance with AG2
Constrained responses via guidance.
guidanceintegrationJSON
FSM - User can input speaker transition constraints
FSM - User can input speaker transition constraints
Explore the demonstration of the Finite State Machine implementation, which allows the user to input speaker transition constraints.
group chatfsmorchestration
Use ChromaDBQueryEngine to query Markdown files
Use ChromaDBQueryEngine to query Markdown files
ChromaDB Query Engine for document queries
agentsdocumentsRAGdocagentchromachromadb
OpenAI Responses API with function call
OpenAI Responses API with function call
This notebook demonstrates how to use tool calling with OpenAI's Responses API.
tool callingtoolsfunction callingresponses
Agent Chat with Async Human Inputs
Agent Chat with Async Human Inputs
Async human inputs.
asynchuman
RAG OpenAI Assistants in AG2
RAG OpenAI Assistants in AG2
OpenAI Assistant with retrieval augmentation.
RAGOpenAI Assistant
Task Solving with Code Generation, Execution and Debugging
Task Solving with Code Generation, Execution and Debugging
Use conversable language learning model agents to solve tasks and provide automatic feedback through a comprehensive example of writing, executing, and debugging Python code to compare stock price changes.
code generation
StateFlow: Build Workflows through State-Oriented Actions
StateFlow: Build Workflows through State-Oriented Actions
StateFlow: Build workflows through state-oriented actions.
orchestrationgroup chatstateflowresearch
Auto Generated Agent Chat: GPTAssistant with Code Interpreter
Auto Generated Agent Chat: GPTAssistant with Code Interpreter
This Jupyter Notebook showcases the integration of the Code Interpreter tool which executes Python code dynamically within applications.
OpenAI Assistantcode interpreter
RemyxCodeExecutor: Agentic Code Exploration and Execution
RemyxCodeExecutor: Agentic Code Exploration and Execution
AI-guided exploration and execution of research paper codebases using RemyxCodeExecutor
code executiondockerresearchremyx
Runtime Logging with AG2
Runtime Logging with AG2
Provide capabilities of runtime logging for debugging and performance analysis.
loggingdebugging
ReasoningAgent - Advanced LLM Reasoning with Multiple Search Strategies
ReasoningAgent - Advanced LLM Reasoning with Multiple Search Strategies
Use ReasoningAgent for o1 style reasoning in Agentic workflows with LLMs using AG2
reasoning agenttree of thoughts
Wikipedia Search Tools
Wikipedia Search Tools
Perplexity Search Integration with AG2
toolsperplexityweb-searchsearch
AutoBuild
AutoBuild
Automatically build multi-agent system with AgentBuilder
autobuild
Using RetrieveChat for Retrieve Augmented Code Generation and Question Answering
Using RetrieveChat for Retrieve Augmented Code Generation and Question Answering
Explore the use of AG2's RetrieveChat for tasks like code generation from docstrings, answering complex questions with human feedback, and exploiting features like Update Context, custom prompts, and few-shot learning.
RAG
SearxNG Search Tool Walkthrough
SearxNG Search Tool Walkthrough
This notebook demonstrates how to use the SearxNG Search Tool for real-time web searches using a privacy-friendly, open-source metasearch engine.
toolsearxngsearchweb
Auto Generated Agent Chat: Teaching AI New Skills via Natural Language Interaction
Auto Generated Agent Chat: Teaching AI New Skills via Natural Language Interaction
Teach the agent news skills using natural language.
learningteaching
Engaging Image Input/Output with OpenAI's Responses API in AG2
Engaging Image Input/Output with OpenAI's Responses API in AG2
This notebook demonstrates how to do image input and image generate through a two agent chat with OpenAI Responses API and gpt-4o.
multimodalresponses
Adding Browsing Capabilities to AG2
Adding Browsing Capabilities to AG2
Adding Browsing Capabilities to AG2
toolsbrowser-usewebscrapingfunction calling
Group Chat with Tools
Group Chat with Tools
Group Chat with Tools
agentstoolsgroupchatusersguides
Using RetrieveChat with Qdrant for Retrieve Augmented Code Generation and Question Answering
Using RetrieveChat with Qdrant for Retrieve Augmented Code Generation and Question Answering
This notebook demonstrates the usage of QdrantRetrieveUserProxyAgent for RAG.
QdrantintegrationRAG
Chatting with a teachable agent
Chatting with a teachable agent
Learn how to persist memories across chat sessions using the Teachability capability
teachabilitylearningRAGcapability
Translating Video audio using Whisper and GPT-3.5-turbo
Translating Video audio using Whisper and GPT-3.5-turbo
Use tools to extract and translate the transcript of a video file.
whispermultimodaltool/function
OpenAI Responses API V2 Client - Complete Guide
OpenAI Responses API V2 Client - Complete Guide
OpenAI Responses API V2 Client with rich UnifiedResponse objects, stateful conversations, and agent integration
openairesponses-apiv2-clientmultimodalagents
Additional Model Request Fields with Amazon Bedrock in AG2
Additional Model Request Fields with Amazon Bedrock in AG2
Additional Model Request Fields with Amazon Bedrock in AG2
modelsbedrockamazon
Iterating Over Agent Runs with AG2
Iterating Over Agent Runs with AG2
Step-by-step execution for debugging and human-in-the-loop workflows
Auto Generated Agent Chat: Task Solving with Langchain Provided Tools as Functions
Auto Generated Agent Chat: Task Solving with Langchain Provided Tools as Functions
Use Langchain tools.
langchainintegrationtool/function
Anthropic Structured Outputs with AG2
Anthropic Structured Outputs with AG2
Anthropic's structured outputs feature provides two powerful modes: JSON Outputs (Get validated JSON responses matching a specific schema) and Strict Tool Use (Guaranteed schema validation for tool inputs).
structured outputanthropic
Agent Chat with Multimodal Models: LLaVA
Agent Chat with Multimodal Models: LLaVA
Leveraging multimodal models like llava.
multimodalllava
DuckDuckGo Search Tool
DuckDuckGo Search Tool
DuckDuckGo Search Tool
toolsDuckDuckGoweb-searchsearch
Automatically Build Multi-agent System from Agent Library
Automatically Build Multi-agent System from Agent Library
Automatically build multi-agent system from agent library
autobuild
Structured Outputs with Amazon Bedrock in AG2
Structured Outputs with Amazon Bedrock in AG2
Use Amazon Bedrock with AG2 to build applications that return structured data.
GPT-5.1 Apply Patch Tool: Complete Guide to Automated Code Editing
GPT-5.1 Apply Patch Tool: Complete Guide to Automated Code Editing
Apply Patch Tool Example for GPT-5.1
toolsapply_patchgpt-5.1gpt-5in-built-tool
Websockets: Streaming input and output using websockets
Websockets: Streaming input and output using websockets
Websockets facilitate real-time, bidirectional communication between web clients and servers, enhancing the responsiveness and interactivity of AG2-powered applications.
websocketsstreaming
Enhanced Swarm Orchestration with AG2
Enhanced Swarm Orchestration with AG2
Swarm Ochestration
orchestrationgroup chatswarm
Group Chat
Group Chat
Explore the utilization of large language models in automated group chat scenarios, where agents perform tasks collectively, demonstrating how they can be configured, interact with each other, and retrieve specific information from external resources.
orchestrationgroup chatcode generation
Creating Custom Events for Run Iteration
Creating Custom Events for Run Iteration
Creating and using custom events for step-by-step execution
custom-eventsrun-itereventsextensibility
Use AG2 in Microsoft Fabric
Use AG2 in Microsoft Fabric
Use AG2 in Microsoft Fabric
agentschatmicrosoftfabricguides
OptiGuide with Nested Chats in AG2
OptiGuide with Nested Chats in AG2
This is a nested chat re-implementation of OptiGuide which is an LLM-based supply chain optimization framework.
Using RetrieveChat Powered by MongoDB Atlas for Retrieve Augmented Code Generation and Question Answering
Using RetrieveChat Powered by MongoDB Atlas for Retrieve Augmented Code Generation and Question Answering
Explore the use of AG2's RetrieveChat for tasks like code generation from docstrings, answering complex questions with human feedback, and exploiting features like Update Context, custom prompts, and few-shot learning.
MongoDBintegrationRAG
Solving Multiple Tasks in a Sequence of Async Chats
Solving Multiple Tasks in a Sequence of Async Chats
Use conversational agents to solve a set of tasks with a sequence of async chats.
orchestrationasyncsequential chats
Web Scraping using Oxylabs Web Scraper API
Web Scraping using Oxylabs Web Scraper API
Use AG2 to Web Scrape with Oxylabs
llmopenaiweb scrapingoxylabs
RealtimeAgent with gemini client
RealtimeAgent with gemini client
RealtimeAgent with gemini client using websockets
realtimewebsocketsgemini
Auto Generated Agent Chat: Solving Tasks Requiring Web Info
Auto Generated Agent Chat: Solving Tasks Requiring Web Info
Solve tasks requiring web info.
webcode generation
RealtimeAgent in a Swarm Orchestration
RealtimeAgent in a Swarm Orchestration
Swarm Ochestration
orchestrationgroup chatswarmrealtime
Making OpenAI Assistants Teachable
Making OpenAI Assistants Teachable
Teach OpenAI assistants.
teachabilitycapabilitylearningRAGOpenAI Assistant
RealtimeAgent in a Swarm Orchestration
RealtimeAgent in a Swarm Orchestration
Swarm Ochestration
orchestrationgroup chatswarm
Agent Tracking with AgentOps
Agent Tracking with AgentOps
Use AgentOps to simplify the development process and monitor your agents in production.
Use OpenLIT to easily monitor AI agents in production with OpenTelemetry.
integrationmonitoringobservabilitydebugging
CaptainAgent
CaptainAgent
Introducing CaptainAgent, a powerful agent that can manage and orchestrate other agents and tools to solve complex tasks.
autobuildCaptainAgent
Task Solving with Provided Tools as Functions (Asynchronous Function Calls)
Task Solving with Provided Tools as Functions (Asynchronous Function Calls)
Learn how to implement both synchronous and asynchronous function calls using AssistantAgent and UserProxyAgent in AutoGen, with examples of their application in individual and group chat settings for task execution with language models.
tool/functionasync
SocietyOfMindAgent
SocietyOfMindAgent
Explore the demonstration of the SocietyOfMindAgent in the AG2 library, which runs a group chat as an internal monologue, but appears to the external world as a single agent, offering a structured way to manage complex interactions among multiple agents and handle issues such as extracting responses from complex dialogues and dealing with context window constraints.
orchestrationnested chatgroup chat
Writing a software application using function calls
Writing a software application using function calls
Equip your agent with functions that can efficiently implement features into your software application.
Use the shell tool with OpenAI's Responses API for filesystem diagnostics, extending capabilities with UNIX utilities, and running multi-step build and test flows.
responsesshellfilesystemautomationcliopenai
Validating Agent Output With FunctionTarget: A Comprehensive Guide to Custom Validation in Multi-Agent Conversations
Validating Agent Output With FunctionTarget: A Comprehensive Guide to Custom Validation in Multi-Agent Conversations
Group Chat FunctionTarget Examples
group chatfunctiontargetgroupchat
From Dad Jokes To Sad Jokes: Function Calling with GPTAssistantAgent
From Dad Jokes To Sad Jokes: Function Calling with GPTAssistantAgent
Use tools in a GPTAssistantAgent Multi-Agent System by utilizing functions such as calling an API and writing to a file.
OpenAI Assistanttool/function
Agent with memory using Mem0
Agent with memory using Mem0
Use Mem0 to create agents with memory.
mem0integrationmemory
Cross-Framework LLM Tool for CaptainAgent
Cross-Framework LLM Tool for CaptainAgent
Cross-Framework LLM Tool for CaptainAgent
toolslangchaincrewai
Grok example with live search
Grok example with live search
Grok example with live search
grokopenai
(Legacy) Implement Swarm-style orchestration with GroupChat
(Legacy) Implement Swarm-style orchestration with GroupChat
(Legacy) Implement Swarm-style orchestration with GroupChat
orchestrationgroup chatstateflowswarm
V1/V2 Client Compatibility Demonstration
V1/V2 Client Compatibility Demonstration
Client V1/V2 Compatibility
openaiclients
Demonstrating the `AgentEval` framework using the task of solving math problems as an example
Demonstrating the `AgentEval` framework using the task of solving math problems as an example
AgentEval: a multi-agent system for assessing utility of LLM-powered applications
eval
Run a standalone AssistantAgent
Run a standalone AssistantAgent
Run a standalone AssistantAgent, browsing the web using the BrowserUseTool
Auto Generated Agent Chat: Task Solving with Provided Tools as Functions
Auto Generated Agent Chat: Task Solving with Provided Tools as Functions
Register function calls using AssistantAgent and UserProxyAgent to execute python or shell code in customized ways. Demonstrating two ways of registering functions.
code generationtool/function
Using ReliableTool to Generate Sub-Questions (Synchronous Version)
Using ReliableTool to Generate Sub-Questions (Synchronous Version)
ReliableTool - Group Chat Example
tool callingtoolsreliable
Structured output
Structured output
LLM providers offer functionality for defining a structure of the messages generated by LLMs, AG2 enables this functionality by propagating a `response_format`, in the LLM configuration for your agents, to the underlying client.
structured output
Using ReliableTool to Generate Sub-Questions (Synchronous Version)
Using ReliableTool to Generate Sub-Questions (Synchronous Version)
ReliableTool - Basic Example
tool callingtoolsreliable
Using RetrieveChat Powered by PGVector for Retrieve Augmented Code Generation and Question Answering
Using RetrieveChat Powered by PGVector for Retrieve Augmented Code Generation and Question Answering
Explore the use of AG2's RetrieveChat for tasks like code generation from docstrings, answering complex questions with human feedback, and exploiting features like Update Context, custom prompts, and few-shot learning.
PGVectorintegrationRAG
Solving Complex Tasks with A Sequence of Nested Chats
Solving Complex Tasks with A Sequence of Nested Chats
Solve complex tasks with one or more sequence chats nested as inner monologue.
nested chatsequential chatsorchestration
Adding YouTube Search Capability to AG2
Adding YouTube Search Capability to AG2
YouTube Search Integration with AG2
toolsyoutubevideosearch
Agent Chat with Multimodal Models: DALLE and GPT-4V
Agent Chat with Multimodal Models: DALLE and GPT-4V
Multimodal agent chat with DALL-E and GPT-4v.
multimodalgpt-4v
Grok-powered SBOM Analysis with AG2
Grok-powered SBOM Analysis with AG2
Using AG2 with Grok to perform SBOM analysis and security vulnerability scanning on Git repositories
grokopenai
Handling errors with the RunResponseProtocol
Handling errors with the RunResponseProtocol
This notebook demonstrates handling errors with the RunResponseProtocol
errorsrunresponseprotocol
Generate Dalle Images With Conversable Agents
Generate Dalle Images With Conversable Agents
Generate images with conversable agents.
capabilitymultimodal
Use AG2 to Tune ChatGPT
Use AG2 to Tune ChatGPT
Use AG2 to Tune ChatGPT
llmhyperparamatertuninggptparameter tuning
Exponential Backoff and Retry Configuration with Amazon Bedrock in AG2
Exponential Backoff and Retry Configuration with Amazon Bedrock in AG2
Configure exponential backoff and retry behavior for Amazon Bedrock API calls in AG2.
Perform research using a group chat with a number of specialized agents.
group chatplanningcode generation
Chat with OpenAI Assistant using function call in AG2: OSS Insights for Advanced GitHub Data Analysis
Chat with OpenAI Assistant using function call in AG2: OSS Insights for Advanced GitHub Data Analysis
This Jupyter Notebook demonstrates how to leverage OSS Insight (Open Source Software Insight) for advanced GitHub data analysis by defining `Function calls` in AG2 for the OpenAI Assistant.
OpenAI Assistanttool/function
Solving Complex Tasks with Nested Chats
Solving Complex Tasks with Nested Chats
Solve complex tasks with a chat nested as inner monologue.
nested chatreflectionreasoningorchestration
Use AG2 to Tune OpenAI Models
Use AG2 to Tune OpenAI Models
Use AG2 to Tune OpenAI Models
llmhyperparamatertuningopenaigptparameter tuning
Group Chat with Coder and Visualization Critic
Group Chat with Coder and Visualization Critic
Explore a group chat example using agents such as a coder and visualization agent.
group chatcode generation
Using Neo4j's native GraphRAG SDK with AG2 agents for Question & Answering
Using Neo4j's native GraphRAG SDK with AG2 agents for Question & Answering
Neo4j Native GraphRAG utilizes a knowledge graph and can be added as a capability to agents.
RAG
Trip planning with a FalkorDB GraphRAG agent using GroupChat
Trip planning with a FalkorDB GraphRAG agent using GroupChat
FalkorDB GraphRAG utilises a knowledge graph and can be added as a capability to agents. Together with a swarm orchestration of agents is highly effective at providing a RAG capability.
This notebook demonstrates a fully autonomous, multi-currency conversion system.
tool callingtoolscurrencygoogle search
Auto Generated Agent Chat: Collaborative Task Solving with Multiple Agents and Human Users
Auto Generated Agent Chat: Collaborative Task Solving with Multiple Agents and Human Users
Involve multiple human users via function calls and nested chat.
humantool/function
Agent with memory using Mem0
Agent with memory using Mem0
Use Mem0 to create agents with memory.
memory
Wikipedia Agent
Wikipedia Agent
Search Wikipedia with WikipediaAgent
toolswikipediasearch
Structured output from json configuration
Structured output from json configuration
OpenAI offers a functionality for defining a structure of the messages generated by LLMs, AutoGen enables this functionality by propagating response_format passed to your agents to the underlying client.
structured output
Interactive LLM Agent Dealing with Data Stream
Interactive LLM Agent Dealing with Data Stream
Automated continual learning from new data.
streamingasynclearning
Config loader utility functions
Config loader utility functions
Config loader utility functions
utilityconfig
Conversational Chess using non-OpenAI clients
Conversational Chess using non-OpenAI clients
LLM-backed agents playing chess with each other using nested chats.
nested chattool/functionorchestration
Using ReliableTool to Generate Sub-Questions (Synchronous Version)
Using ReliableTool to Generate Sub-Questions (Synchronous Version)
ReliableTool - Google Search Example
tool callingtoolsreliablesearchgoogle
Exploring GPT-5: Comparing Verbosity Levels in AG2 AgentChat
Exploring GPT-5: Comparing Verbosity Levels in AG2 AgentChat
GPT5 verbosity example
gpt5verbosity
Perplexity Search Tool
Perplexity Search Tool
Perplexity Search Integration with AG2
toolsperplexityweb-searchsearch
Group Chat with Customized Speaker Selection Method
Group Chat with Customized Speaker Selection Method
Introduce group chat with customized speaker selection method.
orchestrationgroup chat
Conversational Workflows with MCP: A Shakespearean Take on arXiv Abstracts
Conversational Workflows with MCP: A Shakespearean Take on arXiv Abstracts
Conversational Workflows with MCP: A Shakespearean Take on arXiv Abstracts
MCP
RealtimeAgent with local websocket connection
RealtimeAgent with local websocket connection
RealtimeAgent using websockets
realtimewebsockets
Use MongoDBQueryEngine to query Markdown files
Use MongoDBQueryEngine to query Markdown files
Mongo DB Query Engine
agentsdocumentsRAGdocagentmongodbquery
AgentOptimizer: An Agentic Way to Train Your LLM Agent
AgentOptimizer: An Agentic Way to Train Your LLM Agent
AgentOptimizer is able to prompt LLMs to iteratively optimize function/skills of AutoGen agents according to the historical conversation and performance.
optimizationtool/function
Using FalkorGraphRagCapability with agents for GraphRAG Question & Answering
Using FalkorGraphRagCapability with agents for GraphRAG Question & Answering
Using FalkorGraphRagCapability with agents for GraphRAG Question & Answering
RAGFalkorDB
Complete DevOps Pipeline Orchestration with Apply Patch & Shell Tools
Complete DevOps Pipeline Orchestration with Apply Patch & Shell Tools
DevOps with OpenAI Apply Patch & Shell Tools
devopstoolsbuilt-in-toolopenairesponses
Auto Generated Agent Chat: Function Inception
Auto Generated Agent Chat: Function Inception
Function Inception: Enable AG2 agents to update/remove functions during conversations.
function inceptiontool/function
Image Input/Output with OpenAI V2 Client and AG2 Agents
Image Input/Output with OpenAI V2 Client and AG2 Agents
OpenAI V2 Client
openaiclients
Using a local Telemetry server to monitor a GraphRAG agent
Using a local Telemetry server to monitor a GraphRAG agent
FalkorDB GraphRAG utilises a knowledge graph and can be added as a capability to agents. Together with a swarm orchestration of agents is highly effective at providing a RAG capability.
RAGtool/functionswarm
Use LLamaIndexQueryEngine to query Markdown files
Use LLamaIndexQueryEngine to query Markdown files
Use any LlamaIndex vector store as a Query Engine
agentsdocumentsRAGdocagentchromachromadbpinecone
Assistants with Azure Cognitive Search and Azure Identity
Assistants with Azure Cognitive Search and Azure Identity
This notebook demonstrates the use of Assistant Agents in conjunction with Azure Cognitive Search and Azure Identity
integrationRAGAzure IdentityAzure AI Search
Solving Multiple Tasks in a Sequence of Chats with Different Conversable Agent Pairs
Solving Multiple Tasks in a Sequence of Chats with Different Conversable Agent Pairs
Use AG2 to solve a set of tasks with a sequence of chats.
orchestrationsequential chats
Using RetrieveChat Powered by Couchbase Capella for Retrieve Augmented Code Generation and Question Answering
Using RetrieveChat Powered by Couchbase Capella for Retrieve Augmented Code Generation and Question Answering
Explore the use of AG2's RetrieveChat for tasks like code generation from docstrings, answering complex questions with human feedback, and exploiting features like Update Context, custom prompts, and few-shot learning.
RAG
Maris: Fine-Grained Policy-Guided Safeguards Demo
Maris: Fine-Grained Policy-Guided Safeguards Demo
Maris: Fine-Grained Policy-Guided Safeguards Demo
safeguardmarispolicy-guided
WebSurferAgent with Firecrawl Integration
WebSurferAgent with Firecrawl Integration
This notebook demonstrates how to use the WebSurferAgent with the Firecrawl tool for web scraping and crawling.
firecrawltoolscraping
OpenTelemetry Tracing for AG2 Agents
OpenTelemetry Tracing for AG2 Agents
Tracing AG2 agents with OpenTelemetry: instrument agents, LLM calls, and tool execution to observe multi-agent interactions.
Currency Calculator: Task Solving with Provided Tools as Functions
Currency Calculator: Task Solving with Provided Tools as Functions
Learn how to register function calls using AssistantAgent and UserProxyAgent.
tool/function
Conversational Workflows with MCP: A Marie Antoinette Take on The Eiffel Tower
Conversational Workflows with MCP: A Marie Antoinette Take on The Eiffel Tower
Conversational Workflows with MCP: A Marie Antoinette Take on The Eiffel Tower
MCP
Managing Multiple MCP Servers with MCPClientSessionManager
Managing Multiple MCP Servers with MCPClientSessionManager
Learn how to use MCPClientSessionManager to dynamically manage multiple MCP server sessions (stdio and SSE) within tool functions for flexible, resource-efficient agent workflows.
Conversational Workflows with MCP: A French joke on a random Wikipedia article
Conversational Workflows with MCP: A French joke on a random Wikipedia article
Conversational Workflows with MCP: A French joke on a random Wikipedia article
MCP
Group Chat with Retrieval Augmented Generation
Group Chat with Retrieval Augmented Generation
Implement and manage a multi-agent chat system using AG2, where AI assistants retrieve information, generate code, and interact collaboratively to solve complex tasks, especially in areas not covered by their training data.
group chatorchestrationRAG
RAG with DocAgent
RAG with DocAgent
Query documents and web pages with DocAgent
agentsdocumentsRAGdocagent
Solving Multiple Tasks in a Sequence of Chats
Solving Multiple Tasks in a Sequence of Chats
Use conversational agents to solve a set of tasks with a sequence of chats.