AG2 (formerly AutoGen) is an open-source programming framework for building AI agents and facilitating cooperation among multiple agents to solve tasks. It provides fundamental building blocks to create, deploy, and manage AI agents, supporting various LLMs, tool use, autonomous and human-in-the-loop workflows, and multi-agent conversation patterns. The current version is 0.11.5 and it maintains a rapid release cadence with frequent updates and new features.
pip install "ag2[openai]"Verified import paths — ran on the pinned version, not inferred.
This quickstart initializes a `ConversableAgent` with an OpenAI LLM configuration and runs a single-turn conversation. It demonstrates basic agent creation and interaction, requiring the `OPENAI_API_KEY` environment variable to be set.
Monitor the official AG2 documentation and release roadmap for migration guides and adopt the `autogen.beta` API for new projects to ensure future compatibility.
Migrate from `GPTAssistantAgent` to `ConversableAgent`. For multi-agent orchestration, use the unified `GroupChat` pattern and its associated classes (`GroupChat`, `GroupChatManager`).
Install AG2 with the appropriate extra for your desired LLM provider, e.g., `pip install "ag2[openai]"`, `"ag2[gemini]"`, `"ag2[anthropic]"`, etc.
Ensure any custom objects passed within `LLMConfig` implement the `__deepcopy__` method to support deep copying.
Review any custom shell command execution logic. Ensure that commands passed to `ShellExecutor` are properly sanitized and do not rely on `shell=True` behavior if not explicitly intended and secured.
Install the 'ag2' package using pip: 'pip install ag2'.
Upgrade 'ag2' to version 0.2.27 or higher: 'pip install --upgrade ag2'.
Ensure Docker is running, or disable Docker usage by setting 'use_docker' to 'False' in 'code_execution_config'.
Ensure you have installed the correct package, `ag2`, and import classes directly from the `ag2` top-level module (or `autogen` if you are using an alias, after `pip install ag2`). ```bash pip install ag2 ``` Then in your Python code: ```python import ag2 # or, if you prefer the old alias, it should still work after installing ag2 import autogen from autogen import Agent, ConversableAgent ```
First, uninstall any potentially conflicting `autogen` or `pyautogen` packages, then install or upgrade to the official `ag2` package. ```bash pip uninstall autogen pyautogen autogen-agentchat # uninstall all conflicting packages pip install --upgrade ag2 ``` Then ensure your imports are correct, typically `from ag2 import Agent` or `import ag2 as autogen` followed by `autogen.Agent`.