Skip to content

fix(openai): add extra_body field to config models so it survives load_component#7622

Open
octo-patch wants to merge 1 commit intomicrosoft:mainfrom
octo-patch:fix/issue-7418-extra-body-config
Open

fix(openai): add extra_body field to config models so it survives load_component#7622
octo-patch wants to merge 1 commit intomicrosoft:mainfrom
octo-patch:fix/issue-7418-extra-body-config

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #7418

Problem

extra_body was silently dropped when loading an OpenAIChatCompletionClient (or Azure variant) from JSON via load_component(). The root cause was that CreateArguments TypedDict and CreateArgumentsConfigModel Pydantic model both lacked an extra_body field. Pydantic's default behaviour is to silently ignore unknown fields, so any extra_body value specified in the JSON config was discarded during validation — it never reached _from_config or the underlying API call.

Notably, create_kwargs (used by _create_args_from_config) already included "extra_body", so the parameter worked correctly when the client was instantiated directly via Python, but not via load_component().

Solution

Add extra_body: Optional[Dict[str, Any]] to:

  • CreateArguments TypedDict — keeps the type hints complete for direct construction
  • CreateArgumentsConfigModel Pydantic model — allows Pydantic to retain the field during deserialization

No changes were needed to _create_args_from_config or any call sites.

Testing

Added test_extra_body_parameter covering:

  • Direct constructor (extra_body lands in _create_args)
  • load_component round-trip for OpenAI client
  • load_component round-trip for Azure OpenAI client
  • dump_component / load_component cycle

…d_component (fixes microsoft#7418)

The CreateArguments TypedDict and CreateArgumentsConfigModel Pydantic model
both lacked an extra_body field. When loading an OpenAI model client from
JSON via load_component(), Pydantic silently dropped any extra_body value
because the field was unknown to the schema.

The fix adds extra_body: Optional[Dict[str, Any]] to both the TypedDict
and the Pydantic config model, keeping them in sync with the existing
create_kwargs set that already included extra_body.

Adds a test that covers the constructor, load_component round-trip, and
dump/load cycle for both OpenAI and Azure OpenAI clients.
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

1 participant