Skip to main content
This guide shows how to integrate AutoGen agents with LangGraph to leverage features like persistence, streaming, and memory, and then deploy the integrated solution to LangSmith for scalable production use. In this guide we show how to build a LangGraph chatbot that integrates with AutoGen, but you can follow the same approach with other frameworks. Integrating AutoGen with LangGraph provides several benefits:

Prerequisites

  • Python 3.9+
  • Autogen: pip install autogen
  • LangGraph: pip install langgraph
  • OpenAI API key

Setup

Set your your environment:

1. Define AutoGen agent

Create an AutoGen agent that can execute code. This example is adapted from AutoGen’s official tutorials:

2. Create the graph

We will now create a LangGraph chatbot graph that calls AutoGen agent.
LangGraph chatbot with one step: START routes to autogen, where call_autogen_agent sends the latest user message (with prior context) to the AutoGen agent.

3. Test the graph locally

Before deploying to LangSmith, you can test the graph locally:
Output:
Since we’re leveraging LangGraph’s persistence features we can now continue the conversation using the same thread ID — LangGraph will automatically pass previous history to the AutoGen agent:
Output:

4. Prepare for deployment

To deploy to LangSmith, create a file structure like the following:

5. Deploy to LangSmith

Deploy the graph with the LangSmith CLI:

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.