Sitelet https://github.com/microsoft/autogen/pull/8077
Skip to content

fix(autogen-ext): add extra_body to OpenAI client config and serialization models - #8077

Open
Muhammad Maaz (Maazkorejo) wants to merge 2 commits into
microsoft:mainfrom
Maazkorejo:fix/openai-client-extra-body
Open

fix(autogen-ext): add extra_body to OpenAI client config and serialization models#8077
Muhammad Maaz (Maazkorejo) wants to merge 2 commits into
microsoft:mainfrom
Maazkorejo:fix/openai-client-extra-body

Conversation

@Maazkorejo

Copy link
Copy Markdown

Description

Fixes #7418

OpenAIChatCompletionClient supported extra_body in runtime create args, but extra_body was missing from CreateArguments (TypedDict) and CreateArgumentsConfigModel (Pydantic model) in autogen_ext.models.openai.config.

As a result, configuring extra_body through component configurations (e.g., in AutoGen Studio or ChatCompletionClient.load_component(...)) silently dropped the field.

Changes Made

  • Added extra_body: Optional[Dict[str, Any]] to CreateArguments in src/autogen_ext/models/openai/config/__init__.py.
  • Added extra_body: Dict[str, Any] | None = None to CreateArgumentsConfigModel.
  • Added unit test test_extra_body_configuration_and_serialization in tests/models/test_openai_model_client.py verifying client initialization, load_component, and dump_component roundtrips.

Checklist

…ation models

Signed-off-by: Muhammad Maaz <maazkorejo00@gmail.com>
@Maazkorejo

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@EsanRAHIMI Esan (EsanRAHIMI) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration additions look consistent with the runtime create arguments, and covering both direct initialization and component loading is useful. One coverage gap is that the serialization assertion only inspects the reloaded client's private _create_args; it never asserts the public dump_component() payload itself. If dumping silently omitted extra_body and another path repopulated it, this test could give a misleading result. Could the test assert dumped.config.extra_body (or the equivalent serialized field) before reloading, and also verify the reloaded public dump round-trip? That would pin the exact component-serialization boundary this PR is intended to fix.

@Maazkorejo

Copy link
Copy Markdown
Author

Hi Esan (@EsanRAHIMI) , thanks for the review!

I have updated the test suite to:

  1. Directly assert dumped.config.extra_body on the public dump_component() payload prior to reloading.
  2. Assert reloaded.dump_component().config.extra_body to verify the reloaded client's public dump round-trip.
  3. Added matching public dump and reload round-trip assertions for AzureOpenAIChatCompletionClient as well.

The updated commit has been pushed to the PR branch!

@EsanRAHIMI Esan (EsanRAHIMI) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. The new assertions directly cover the public dump payload and the post-reload public round-trip, including the Azure client path. This addresses my review feedback.

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.

extra_body in OpenAIChatCompletionClient config is silently ignored when loaded via AutoGen Studio JSON

2 participants