Skip to content

Python: Support OpenAI message "name" field #2951

@gdhuang

Description

@gdhuang

Background
The Python SDK does not currently map the ChatMessage.author_name field to OpenAI's optional "name" field when sending messages to the OpenAI completion API.
This field is useful for identifying different participants in conversations.

Current Behavior
In the Python implementation, the ChatMessage class has an author_name attribute.
However, when converting messages to OpenAI format in _openai_chat_message_parser(), the author_name is not included:
File: python/packages/core/agent_framework/openai/_chat_client.py:364-393

Expected Behavior

The author_name should be mapped to OpenAI's "name" field when present, similar to how the .NET implementation handles it.

string? name = SanitizeAuthorName(input.AuthorName);

File: https://github.com/dotnet/extensions/blob/main/src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIChatClient.cs:158

Metadata

Metadata

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions