⚠️This is documentation for AG2 Classic (autogen package), which is in maintenance mode. For the latest version, use AG2 v1.0+ (ag2 package) at docs.ag2.ai.
All Notebooks
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.
Runtime Logging with AG2
Runtime Logging with AG2
Provide capabilities of runtime logging for debugging and performance analysis.
loggingdebugging
Using ReliableTool to Generate Sub-Questions (Synchronous Version)
Using ReliableTool to Generate Sub-Questions (Synchronous Version)
ReliableTool - Basic Example
tool callingtoolsreliable
Image Input/Output with OpenAI V2 Client and AG2 Agents
Image Input/Output with OpenAI V2 Client and AG2 Agents
OpenAI V2 Client
openaiclients
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 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
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
Using Guidance with AG2
Using Guidance with AG2
Constrained responses via guidance.
guidanceintegrationJSON
Agent Tracking with AgentOps
Agent Tracking with AgentOps
Use AgentOps to simplify the development process and monitor your agents in production.
integrationmonitoringdebugging
Auto Generated Agent Chat: Collaborative Task Solving with Coding and Planning Agent
Auto Generated Agent Chat: Collaborative Task Solving with Coding and Planning Agent
Use planning agent in a function call.
planningorchestrationnested chattool/function
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.
orchestrationsequential chats
Shell Tool with OpenAI Responses API
Shell Tool with OpenAI Responses API
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
Amazon Bedrock V2 Client with AG2
Amazon Bedrock V2 Client with AG2
Amazon Bedrock V2 Client with AG2 - Rich UnifiedResponse and Structured Outputs
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
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.
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
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.
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
Web Scraping using Apify Tools
Web Scraping using Apify Tools
Scrapping web pages and summarizing the content using agents with tools.
webapifyintegrationtool/function
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
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
AG2 + Gemini Thinking Config Variants
AG2 + Gemini Thinking Config Variants
Google Gemini Thinking
googlegeminithinking
Google Drive Tools
Google Drive Tools
Google Drive Tools
agentstoolsgoogle drive
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.
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
Grok example with live search
Grok example with live search
Grok example with live search
grokopenai
Maris: Fine-Grained Policy-Guided Safeguards Demo
Maris: Fine-Grained Policy-Guided Safeguards Demo
Maris: Fine-Grained Policy-Guided Safeguards Demo
safeguardmarispolicy-guided
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
Veronica Core: Circuit Breaker for AG2 Agents
Veronica Core: Circuit Breaker for AG2 Agents
Use veronica-core's CircuitBreakerCapability to add per-agent circuit breakers and system-wide SAFE_MODE to AG2 multi-agent workflows.
toolsveronicacircuit-breakerlocal-llmreliability
Tools with Dependency Injection
Tools with Dependency Injection
Tools Dependency Injection
toolsdependency injectionfunction calling
Cross-Framework LLM Tool Integration with AG2
Cross-Framework LLM Tool Integration with AG2
Cross-Framework LLM Tool Integration with AG2
toolslangchainpydanticai
Wikipedia Agent
Wikipedia Agent
Search Wikipedia with WikipediaAgent
toolswikipediasearch
Group Chat with Tools
Group Chat with Tools
Group Chat with Tools
agentstoolsgroupchatusersguides
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
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.
StateFlow: Build Workflows through State-Oriented Actions
StateFlow: Build Workflows through State-Oriented Actions
StateFlow: Build workflows through state-oriented actions.
orchestrationgroup chatstateflowresearch
Use MongoDBQueryEngine to query Markdown files
Use MongoDBQueryEngine to query Markdown files
Mongo DB Query Engine
agentsdocumentsRAGdocagentmongodbquery
Using ReliableTool to Generate Sub-Questions (Synchronous Version)
Using ReliableTool to Generate Sub-Questions (Synchronous Version)
ReliableTool - Google Search Example
tool callingtoolsreliablesearchgoogle
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
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
Daytona Executor: Sandbox Code Execution for AG2 Agents
Daytona Executor: Sandbox Code Execution for AG2 Agents
Use AG2 to execute code in secure, isolated Daytona cloud sandboxes
code-executiondaytonasandboxmulti-language
Agent Chat with Async Human Inputs
Agent Chat with Async Human Inputs
Async human inputs.
asynchuman
Handling errors with the RunResponseProtocol
Handling errors with the RunResponseProtocol
This notebook demonstrates handling errors with the RunResponseProtocol
Explore a group chat example using agents such as a coder and visualization agent.
group chatcode generation
Adding YouTube Search Capability to AG2
Adding YouTube Search Capability to AG2
YouTube Search Integration with AG2
toolsyoutubevideosearch
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
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
Adding Google Search Capability to AG2
Adding Google Search Capability to AG2
Google Search
agentstoolssearchwebgooglereal-time search
Usage tracking with AG2
Usage tracking with AG2
cost calculation
cost
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
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
Solving Complex Tasks with Nested Chats
Solving Complex Tasks with Nested Chats
Solve complex tasks with a chat nested as inner monologue.
nested chatreflectionreasoningorchestration
Load the configuration including the response format
Load the configuration including the response format
Agent Quickstart Examples
agentstoolsquickstartexamplesautogen
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
YepCode Executor: Serverless Code Execution for AG2 Agents
YepCode Executor: Serverless Code Execution for AG2 Agents
Use AG2 to execute code with YepCode
llmopenaiyepcode
Perplexity Search Tool
Perplexity Search Tool
Perplexity Search Integration with AG2
toolsperplexityweb-searchsearch
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
Exploring GPT-5: Comparing Verbosity Levels in AG2 AgentChat
Exploring GPT-5: Comparing Verbosity Levels in AG2 AgentChat
GPT5 verbosity example
gpt5verbosity
Cross-Framework LLM Tool for CaptainAgent
Cross-Framework LLM Tool for CaptainAgent
Cross-Framework LLM Tool for CaptainAgent
toolslangchain
Using ReliableTool to Generate Sub-Questions (Synchronous Version)
Using ReliableTool to Generate Sub-Questions (Synchronous Version)
ReliableTool - Group Chat Example
tool callingtoolsreliable
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
Supercharging Web Crawling with Crawl4AI
Supercharging Web Crawling with Crawl4AI
Supercharging Web Crawling with Crawl4AI
toolsbrowser-usewebscrapingfunction calling
Language Agent Tree Search
Language Agent Tree Search
Language Agent Tree Search.
LATSsearchreasoningreflection
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
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.