-
Notifications
You must be signed in to change notification settings - Fork 813
.NET: Fix: OpenAI ChatClients do not send entity_id in AgentChatWebEx… #2378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an issue where OpenAI ChatClients were not sending the required entity_id metadata in the AgentChatWebExample. The fix adds RawRepresentationFactory to the ChatOptions to supply the correct metadata for HostedAgentResponseExecutor.
Key Changes
- Added
RawRepresentationFactorytoChatOptionsin both OpenAI client implementations to includeentity_idmetadata - Added
using OpenAI.Responses;namespace inOpenAIChatCompletionsAgentClient.cs
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| dotnet/samples/AgentWebChat/AgentWebChat.Web/OpenAIResponsesAgentClient.cs | Added RawRepresentationFactory to create ResponseCreationOptions with entity_id metadata |
| dotnet/samples/AgentWebChat/AgentWebChat.Web/OpenAIChatCompletionsAgentClient.cs | Added using statement for OpenAI.Responses, introduced chatOptions variable with RawRepresentationFactory to create ChatCompletionOptions with entity_id metadata |
| }; | ||
|
|
||
| var openAiClient = new OpenAIResponseClient(model: agentName, credential: new ApiKeyCredential("dummy-key"), options: options).AsIChatClient(); | ||
| var chatOptions = new ChatOptions() |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the C# Sample Code Guidelines, prefer defining variables using explicit types rather than var to help users understand the types involved. Change var chatOptions to ChatOptions chatOptions.
| await foreach (var update in openAiClient.GetStreamingResponseAsync(messages, cancellationToken: cancellationToken)) | ||
|
|
||
| var chatOptions = new ChatOptions() | ||
| { |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the C# Sample Code Guidelines, prefer defining variables using explicit types rather than var to help users understand the types involved. Change var chatOptions to ChatOptions chatOptions.
| Transport = new HttpClientPipelineTransport(httpClient) | ||
| }; | ||
|
|
||
| var openAiClient = new OpenAIResponseClient(model: agentName, credential: new ApiKeyCredential("dummy-key"), options: options).AsIChatClient(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also has a problem, because you will have to pass a LLM model in the model name and not the agent name.
This is quite strange that you will have to pass the model and the agent whereas the agent also defines which model to use.
Modified the OpenAI clients in AgentChatWebExample to send the needed metadata.
Motivation and Context
Fixes #2376
Description
I've added RawRepresentationFactory as suggested with now supplies the correct metadata for HostedAgentResponseExecutor.
Contribution Checklist