AutoGen (Microsoft)
Microsoft's framework for building multi-agent AI applications. As of v0.4+, AutoGen is a layered system: autogen-core (event-driven actor runtime), autogen-agentchat (high-level conversational agents), and autogen-ext (extensions for OpenAI, Azure, MCP, etc.). Completely async. The 0.2 API is a separate, deprecated architecture. NOT the same as AG2.
Warnings
- breaking AutoGen v0.4+ is a complete ground-up rewrite with a fully incompatible API from v0.2. All v0.2 imports (from autogen.agentchat, autogen.oai, AssistantAgent with llm_config dict, UserProxyAgent) are broken in v0.4.
- breaking All v0.4+ AutoGen APIs are fully async. Calling agent.run() without await in an async context, or calling it in a sync context without asyncio.run(), will fail or produce no output.
- breaking OpenAIChatCompletionClient is in autogen-ext, not autogen-agentchat. pip install autogen-agentchat alone is insufficient — model clients require autogen-ext[openai] or the relevant provider extra.
- breaking pyautogen on PyPI is no longer maintained by Microsoft as of v0.2.34+. Control of that package was lost to an AG2-affiliated fork. Do not use pyautogen for Microsoft AutoGen.
- gotcha AG2 (pip install ag2 or pip install autogen) is a community fork of AutoGen 0.2, NOT Microsoft's AutoGen 0.4. The autogen PyPI package is currently controlled by the AG2 project. Code written for AG2 and code written for Microsoft AutoGen 0.4 are NOT compatible.
- gotcha LLM-generated AutoGen code is highly unreliable. Most AI assistants (as of early 2026) mix v0.2 and v0.4 imports, use wrong module paths (autogen_core.components vs autogen_core), or use synchronous patterns on async-only APIs.
- gotcha model_client.close() must be explicitly called after use to avoid resource leaks. The client does not auto-close.
Install
-
pip install -U "autogen-agentchat" "autogen-ext[openai]" -
pip install -U autogen-core -
pip install -U autogenstudio
Imports
- AssistantAgent (v0.4+)
from autogen_agentchat.agents import AssistantAgent from autogen_ext.models.openai import OpenAIChatCompletionClient
- RoutedAgent (Core API)
from autogen_core import RoutedAgent, message_handler
Quickstart
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
async def main() -> None:
model_client = OpenAIChatCompletionClient(model='gpt-4o')
agent = AssistantAgent('assistant', model_client=model_client)
result = await agent.run(task='Say Hello World!')
print(result)
await model_client.close()
asyncio.run(main())