AG2, distributed via the 'autogen' PyPI package, is an open-source programming framework for building AI agents and facilitating cooperation among multiple agents to solve tasks. It aims to streamline the development and research of agentic AI, offering features such as multi-agent conversations, support for various large language models (LLMs) and tool use, autonomous and human-in-the-loop workflows. The library is actively maintained with frequent minor releases, currently at version 0.11.5, and is on a roadmap towards a major v1.0 release.
pip install "ag2[openai]"Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a simple 'ConversableAgent' with an LLM configuration and run an interaction. It uses OpenAI's API, expecting `OPENAI_API_KEY` to be set as an environment variable. The `run()` method prepares the conversation, and `process()` executes it.
Monitor the official AG2 documentation and release roadmap for migration guides and updated API usage as v1.0 approaches. Begin experimenting with `autogen.beta` for new projects.
Ensure you install AG2 with the necessary extras, e.g., `pip install "ag2[openai]"` for OpenAI support, or `pip install "ag2[gemini,anthropic]"` for multiple providers.
Wrap the package and extras in double quotes: `pip install "ag2[openai]"`.
Ensure Docker Desktop or your Docker environment is running and accessible. For non-Docker code execution, configure `code_execution_config={'use_docker': False}` for `UserProxyAgent`.Review your `LLMConfig` dictionary. Ensure all necessary keys like `api_type`, `model`, and `api_key` are present and correctly formatted, matching the requirements of your chosen LLM provider.
Inspect the agent's reply logic or custom functions where the 'task' variable is used. Ensure 'task' is always initialized or passed correctly before being accessed. Debug the agent's conversation flow to pinpoint when and why 'task' might be unassigned.
Upgrade to `ag2` version 0.11.1 or newer, as this specific `TypeError` was addressed in that release. If the issue persists with the latest version, verify the tool's expected return format against its actual output.
Ensure that every agent participating in a `GroupChat` has a unique `name` attribute. For example: `agent1 = ConversableAgent(name="Coder", ...)` and `agent2 = ConversableAgent(name="Reviewer", ...)`.