KEMBAR78
Feature: Add OpenAIAgent backed by OpenAI Response API by jay-thakur · Pull Request #6418 · microsoft/autogen · GitHub
Skip to content

Conversation

@jay-thakur
Copy link
Contributor

Why are these changes needed?

This PR introduces a new OpenAIAgent implementation that uses the OpenAI Response API 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


Related issue number

Closes #6032

Checks

@codecov
Copy link

codecov bot commented Apr 28, 2025

Codecov Report

Attention: Patch coverage is 87.09677% with 36 lines in your changes missing coverage. Please review.

Project coverage is 79.68%. Comparing base (b0c8002) to head (6bd53a2).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ext/src/autogen_ext/agents/openai/_openai_agent.py 87.00% 36 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6418      +/-   ##
==========================================
+ Coverage   79.55%   79.68%   +0.12%     
==========================================
  Files         225      226       +1     
  Lines       16686    16964     +278     
==========================================
+ Hits        13275    13517     +242     
- Misses       3411     3447      +36     
Flag Coverage Δ
unittests 79.68% <87.09%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jay-thakur
Copy link
Contributor Author

ack all comments.

@bassmang
Copy link
Contributor

ack all comments.

@jay-thakur are you working on addressing these? If not I'm happy to pick them up

@jay-thakur
Copy link
Contributor Author

yes, I am. will address all these comments and raise updated PR. @bassmang

@jay-thakur jay-thakur force-pushed the feature/response-api-impl branch from f97b640 to 6fcb1e4 Compare June 1, 2025 20:28
@jay-thakur
Copy link
Contributor Author

@bassmang, @withsmilo, @ekzhu

I have addressed the comments. Kindly review.

@bassmang bassmang merged commit d1d664b into microsoft:main Jun 3, 2025
64 checks passed
@sumit03guha
Copy link

I want to achieve the following web search capability

response = client.responses.create(
    model="gpt-4.1",
    tools=[{"type": "web_search_preview"}],
    input="What was a positive news story from today?"
)

How do I add the web_search_preview tool to an autogen agent created using the OpenAIAgent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce OpenAIAgent backed by the Response API in Extensions.

5 participants