
## Why are these changes needed? This PR introduces a new `OpenAIAgent` implementation that uses the [OpenAI Response API](https://platform.openai.com/docs/guides/responses-vs-chat-completions) as its backend. The OpenAI Assistant API will be deprecated in 2026, and the Response API is its successor. This change ensures our codebase is future-proof and aligned with OpenAI’s latest platform direction. ### Motivation - **Deprecation Notice:** The OpenAI Assistant API will be deprecated in 2026. - **Future-Proofing:** The Response API is the recommended replacement and offers improved capabilities for stateful, multi-turn, and tool-augmented conversations. - **AgentChat Compatibility:** The new agent is designed to conform to the behavior and expectations of `AssistantAgent` in AgentChat, but is implemented directly on top of the OpenAI Response API. ### Key Changes - **New Agent:** Adds `OpenAIAgent`, a stateful agent that interacts with the OpenAI Response API. - **Stateful Design:** The agent maintains conversation state, tool usage, and other metadata as required by the Response API. - **AssistantAgent Parity:** The new agent matches the interface and behavior of `AssistantAgent` in AgentChat, ensuring a smooth migration path. - **Direct OpenAI Integration:** Uses the official `openai` Python library for all API interactions. - **Extensible:** Designed to support future enhancements, such as advanced tool use, function calling, and multi-modal capabilities. ### Migration Path - Existing users of the Assistant API should migrate to the new `OpenAIAgent` to ensure long-term compatibility. - Documentation and examples will be updated to reflect the new agent and its usage patterns. ### References - [OpenAI: Responses vs. Chat Completions](https://platform.openai.com/docs/guides/responses-vs-chat-completions) - [OpenAI Deprecation Notice](https://platform.openai.com/docs/guides/responses-vs-chat-completions#deprecation-timeline) --- ## Related issue number Closes #6032 ## Checks - [ ] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com/microsoft/autogen/blob/main/CONTRIBUTING.md> to build and test documentation locally. - [X] I've added tests (if relevant) corresponding to the changes introduced in this PR. - [X] I've made sure all auto checks have passed. Co-authored-by: Griffin Bassman <griffinbassman@gmail.com>
AutoGen Python packages
This directory works as a single uv
workspace containing all project packages. See packages
to discover all project packages.
Migrating from 0.2.x?
Please refer to the migration guide for how to migrate your code from 0.2.x to 0.4.x.
Development
TL;DR, run all checks with:
uv sync --all-extras
source .venv/bin/activate
poe check
Setup
uv
is a package manager that assists in creating the necessary environment and installing packages to run AutoGen.
Note: To prevent incompatibilities between versions the same UV version as is running in CI should be used. Check the version in CI by looking the setup-uv
action, here for example.
For example, to change your version to 0.5.18
, run:
uv self update 0.5.18
Virtual Environment
During development, you may need to test changes made to any of the packages.
To do so, create a virtual environment where the AutoGen packages are installed based on the current state of the directory.
Run the following commands at the root level of the Python directory:
uv sync --all-extras
source .venv/bin/activate
uv sync --all-extras
will create a.venv
directory at the current level and install packages from the current directory along with any other dependencies. Theall-extras
flag adds optional dependencies.source .venv/bin/activate
activates the virtual environment.
Common Tasks
To create a pull request (PR), ensure the following checks are met. You can run each check individually:
- Format:
poe format
- Lint:
poe lint
- Test:
poe test
- Mypy:
poe mypy
- Pyright:
poe pyright
- Build docs:
poe --directory ./packages/autogen-core/ docs-build
- Auto rebuild+serve docs:
poe --directory ./packages/autogen-core/ docs-serve
- Check samples in
python/samples
:poe samples-code-check
Alternatively, you can run all the checks with: poe check
Note
These need to be run in the virtual environment.
Syncing Dependencies
When you pull new changes, you may need to update the dependencies.
To do so, first make sure you are in the virtual environment, and then in the python
directory, run:
uv sync --all-extras
This will update the dependencies in the virtual environment.
Creating a New Package
To create a new package, similar to autogen-core
or autogen-chat
, use the following:
uv sync --python 3.12
source .venv/bin/activate
cookiecutter ./templates/new-package/