{"id":5102,"library":"ag2","title":"AG2: Open-Source AgentOS for AI Agents","description":"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.","status":"active","version":"0.11.5","language":"en","source_language":"en","source_url":"https://github.com/ag2ai/ag2","tags":["AI","agents","multi-agent","LLM","framework","orchestration","tool-use"],"install":[{"cmd":"pip install \"ag2[openai]\"","lang":"bash","label":"Install with OpenAI support"},{"cmd":"pip install \"ag2[gemini,anthropic]\"","lang":"bash","label":"Install with multiple LLM providers"},{"cmd":"pip install ag2","lang":"bash","label":"Minimal installation (no LLM providers)"}],"dependencies":[{"reason":"Requires Python version >= 3.10 and < 3.14.","package":"python","optional":false},{"reason":"Required for OpenAI LLM integrations. Other providers (e.g., Gemini, Anthropic) require installing their respective extras.","package":"openai","optional":true}],"imports":[{"note":"The primary class for creating flexible, conversational AI agents.","symbol":"ConversableAgent","correct":"from autogen import ConversableAgent"},{"note":"Used to define the configuration for Language Model interactions.","symbol":"LLMConfig","correct":"from autogen import LLMConfig"},{"note":"For orchestrating conversations among multiple agents.","symbol":"GroupChat","correct":"from autogen import GroupChat"},{"note":"Manages the flow and speaker selection within a GroupChat.","symbol":"GroupChatManager","correct":"from autogen import GroupChatManager"},{"note":"The `autogen.beta` module introduces a redesigned agent framework, which will become the official `ag2` v1.0 API. While `from ag2 import Agent` might be seen in some older examples or specific contexts, the future-proof path is `autogen.beta.Agent`.","wrong":"from ag2 import Agent","symbol":"Agent (beta)","correct":"from autogen.beta import Agent"}],"quickstart":{"code":"import os\nfrom autogen import ConversableAgent, LLMConfig\n\n# Ensure your OpenAI API key is set as an environment variable\n# For example: export OPENAI_API_KEY=\"YOUR_API_KEY\"\n\nopenai_api_key = os.environ.get(\"OPENAI_API_KEY\", \"\")\n\nif not openai_api_key:\n    print(\"Error: OPENAI_API_KEY environment variable is not set.\")\n    exit()\n\nllm_config = LLMConfig(\n    {\n        \"api_type\": \"openai\",\n        \"model\": \"gpt-5-nano\",\n        \"api_key\": openai_api_key\n    }\n)\n\n# Create a poetic AI assistant\nmy_agent = ConversableAgent(\n    name=\"helpful_agent\",\n    system_message=\"You are a poetic AI assistant, respond in rhyme.\",\n    llm_config=llm_config,\n)\n\n# Run the agent with a prompt\nresponse = my_agent.run(\n    message=\"In one sentence, what's the big deal about AI?\",\n    max_turns=1, # Limit turns for a quick, non-interactive example\n    user_input=False, # Disable human input for automatic execution\n)\n\n# Print the agent's final response\nif response.chat_history:\n    print(response.chat_history[-1][\"content\"])\nelse:\n    print(\"No response generated.\")","lang":"python","description":"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."},"warnings":[{"fix":"Monitor the official AG2 documentation and release roadmap for migration guides and adopt the `autogen.beta` API for new projects to ensure future compatibility.","message":"AG2 is transitioning from its original framework (autogen.agentchat) to a new, redesigned beta framework (autogen.beta) which will become the official v1.0. This will involve deprecations and architectural changes in upcoming minor versions (v0.12, v0.13, v0.14) before the beta becomes stable at v1.0. Users should plan for migration.","severity":"breaking","affected_versions":"0.11.x to 1.0"},{"fix":"Migrate from `GPTAssistantAgent` to `ConversableAgent`. For multi-agent orchestration, use the unified `GroupChat` pattern and its associated classes (`GroupChat`, `GroupChatManager`).","message":"The `GPTAssistantAgent` class is deprecated as of v0.12 and will be removed in v0.14. Similarly, the `Swarm` orchestration pattern (and related functions like `initiate_swarm_chat()`) has been deprecated since v0.9 in favor of the new `GroupChat` pattern.","severity":"deprecated","affected_versions":"0.9+, 0.12+"},{"fix":"Install AG2 with the appropriate extra for your desired LLM provider, e.g., `pip install \"ag2[openai]\"`, `\"ag2[gemini]\"`, `\"ag2[anthropic]\"`, etc.","message":"LLM provider packages are not installed by default with `pip install ag2`. Users must explicitly install them as extras (e.g., `pip install \"ag2[openai]\"`) for their chosen LLM provider to function.","severity":"gotcha","affected_versions":"0.8+"},{"fix":"Ensure any custom objects passed within `LLMConfig` implement the `__deepcopy__` method to support deep copying.","message":"The `LLMConfig` object uses `deepcopy` internally to prevent unintended modifications. If `llm_config` contains custom objects that do not implement a `__deepcopy__` method, it can lead to `TypeError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"As of v0.11.4, `ShellExecutor` now uses `shell=False` with `shlex.split` to prevent shell command injection vulnerabilities. Previously, users might have inadvertently created insecure execution environments.","severity":"security","affected_versions":"0.11.4+"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}