Skip to content

Commit d1d664b

Browse files
jay-thakurbassmang
andauthored
Feature: Add OpenAIAgent backed by OpenAI Response API (#6418)
## 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>
1 parent b0c8002 commit d1d664b

File tree

3 files changed

+1286
-2
lines changed

3 files changed

+1286
-2
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
try:
2+
from ._openai_agent import OpenAIAgent
23
from ._openai_assistant_agent import OpenAIAssistantAgent
34
except ImportError as e:
45
raise ImportError(
5-
"Dependencies for OpenAIAssistantAgent not found. "
6+
"Dependencies for OpenAI agents not found. "
67
'Please install autogen-ext with the "openai" extra: '
78
'pip install "autogen-ext[openai]"'
89
) from e
910

10-
__all__ = ["OpenAIAssistantAgent"]
11+
__all__ = ["OpenAIAssistantAgent", "OpenAIAgent"]

0 commit comments

Comments
 (0)