ag2 icon indicating copy to clipboard operation
ag2 copied to clipboard

Fix groupchat responses api

Open tejas-dharani opened this issue 4 months ago • 6 comments

Why are these changes needed?

This PR resolves a compatibility issue that caused GroupChat to fail when using OpenAI’s Responses API. Added streaming response support and proper ID handling for Responses API. It also improves validation and error handling for more reliable performance.

Related issue number

Closes: #2022

Checks

tejas-dharani avatar Aug 14 '25 20:08 tejas-dharani

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 14 '25 20:08 CLAassistant

Thanks for creating this @tejas-dharani.

I think we should avoid changing the speaker selection template prompt as I believe it can be changed through the API and changing the default will affect those already using it.

In conjunction with that, the speaker selection choosing the same agent again isn't a restriction that I think we should have as it may be very valid for an agent to be selected again (e.g. it has been determined that they have not finished their task).

marklysze avatar Aug 14 '25 20:08 marklysze

@tejas-dharani Before diving into the implementation details, I would like to clarify a few things,

  1. Chat completion APIs&Clients is not just for OAI but also for all OAI compatible models, e.g. deepseek, Bedrock etc (basically except Gemini all other models are compatible to chat completion)
  2. Responsible API is OAI only for now.
  3. AG2 supports agent orchestration on top of different LLMs which means the change needs to be generic enough.
  4. When you dev, please use the notebook examples to verify if your changes actually works.
  5. Use groupchat to support responses api is not a trivial task. Could you write a one pager or use an issue to discuss before jump into coding?

randombet avatar Aug 15 '25 18:08 randombet

@tejas-dharani Before diving into the implementation details, I would like to clarify a few things,

  1. Chat completion APIs&Clients is not just for OAI but also for all OAI compatible models, e.g. deepseek, Bedrock etc (basically except Gemini all other models are compatible to chat completion)
  2. Responsible API is OAI only for now.
  3. AG2 supports agent orchestration on top of different LLMs which means the change needs to be generic enough.
  4. When you dev, please use the notebook examples to verify if your changes actually works.
  5. Use groupchat to support responses api is not a trivial task. Could you write a one pager or use an issue to discuss before jump into coding?
  • I’ve already tested the changes extensively with my OpenAI API.
  • This was already discussed in issue #2022.

tejas-dharani avatar Aug 18 '25 14:08 tejas-dharani

Codecov Report

:x: Patch coverage is 55.68182% with 39 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
autogen/oai/openai_responses.py 50.00% 17 Missing and 7 partials :warning:
autogen/oai/client_utils.py 44.00% 8 Missing and 6 partials :warning:
autogen/agentchat/groupchat.py 93.33% 0 Missing and 1 partial :warning:
Files with missing lines Coverage Δ
autogen/agentchat/groupchat.py 67.78% <93.33%> (-3.51%) :arrow_down:
autogen/oai/client_utils.py 81.92% <44.00%> (-12.90%) :arrow_down:
autogen/oai/openai_responses.py 72.65% <50.00%> (+2.70%) :arrow_up:

... and 40 files with indirect coverage changes

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

codecov[bot] avatar Aug 20 '25 22:08 codecov[bot]

@randombet do you have any further comments on this?

marklysze avatar Sep 16 '25 19:09 marklysze