Add include_name_in_message parameter to make name field optional in OpenAI messages#6845
Merged
Add include_name_in_message parameter to make name field optional in OpenAI messages#6845
include_name_in_message parameter to make name field optional in OpenAI messages#6845Conversation
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
… parameter Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Make usage of
Add Jul 23, 2025
name field in OpenAI messages optional in OpenAIChatCompletionClientinclude_name_in_message parameter to make name field optional in OpenAI messages
ekzhu
approved these changes
Jul 27, 2025
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6845 +/- ##
=======================================
Coverage 79.91% 79.92%
=======================================
Files 235 235
Lines 18172 18184 +12
=======================================
+ Hits 14523 14533 +10
- Misses 3649 3651 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Many OpenAI-compatible model providers (like Groq, Together AI, etc.) don't support the
namefield in chat completion messages, causing API errors when using AutoGen with these providers.This PR adds an
include_name_in_messageparameter toBaseOpenAIChatCompletionClientthat controls whether thenamefield is included in message parameters sent to the API.Changes
include_name_in_message: boolparameter toBaseOpenAIClientConfigurationand related Pydantic modelsBaseOpenAIChatCompletionClient,OpenAIChatCompletionClient, andAzureOpenAIChatCompletionClientconstructors to handle the new parameter_set_name()function to conditionally include the name field based on contextto_oai_type()andcount_tokens_openai()functions to pass the parameter through the transformation pipelineUsage
Standard OpenAI (default behavior)
Groq (disable name field)
Alternative: Use name prefixes instead
Message Transformation
With name field (
include_name_in_message=True):{ "role": "user", "content": "Hello there!", "name": "User123" }Without name field (
include_name_in_message=False):{ "role": "user", "content": "Hello there!" }Backward Compatibility
This change is fully backward compatible:
include_name_in_messagedefaults toTrueFalseThe implementation follows existing patterns (similar to how Mistral models already exclude the name field) and provides consistent control across all model types.
Fixes #6034.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.