diff --git a/dotnet/samples/AgentWebChat/AgentWebChat.Web/OpenAIChatCompletionsAgentClient.cs b/dotnet/samples/AgentWebChat/AgentWebChat.Web/OpenAIChatCompletionsAgentClient.cs index 95e3d16fd4..bcbb11634e 100644 --- a/dotnet/samples/AgentWebChat/AgentWebChat.Web/OpenAIChatCompletionsAgentClient.cs +++ b/dotnet/samples/AgentWebChat/AgentWebChat.Web/OpenAIChatCompletionsAgentClient.cs @@ -28,8 +28,21 @@ public override async IAsyncEnumerable RunStreamingAsync Transport = new HttpClientPipelineTransport(httpClient) }; - var openAiClient = new ChatClient(model: "myModel!", credential: new ApiKeyCredential("dummy-key"), options: options).AsIChatClient(); - await foreach (var update in openAiClient.GetStreamingResponseAsync(messages, cancellationToken: cancellationToken)) + IChatClient openAiClient = new ChatClient(model: nameof(AgentWebChat), credential: new ApiKeyCredential("dummy-key"), options: options).AsIChatClient(); + + ChatOptions chatOptions = new() + { + ConversationId = threadId, + RawRepresentationFactory = _ => new ChatCompletionOptions() + { + Metadata = + { + { "entity_id", agentName } + } + }, + }; + + await foreach (var update in openAiClient.GetStreamingResponseAsync(messages, options: chatOptions, cancellationToken: cancellationToken)) { yield return new AgentRunResponseUpdate(update); } diff --git a/dotnet/samples/AgentWebChat/AgentWebChat.Web/OpenAIResponsesAgentClient.cs b/dotnet/samples/AgentWebChat/AgentWebChat.Web/OpenAIResponsesAgentClient.cs index d0121a6165..1ce9da18ef 100644 --- a/dotnet/samples/AgentWebChat/AgentWebChat.Web/OpenAIResponsesAgentClient.cs +++ b/dotnet/samples/AgentWebChat/AgentWebChat.Web/OpenAIResponsesAgentClient.cs @@ -27,10 +27,18 @@ public override async IAsyncEnumerable RunStreamingAsync Transport = new HttpClientPipelineTransport(httpClient) }; - var openAiClient = new ResponsesClient(model: agentName, credential: new ApiKeyCredential("dummy-key"), options: options).AsIChatClient(); + var openAiClient = new ResponsesClient(model: nameof(AgentWebChat), credential: new ApiKeyCredential("dummy-key"), options: options).AsIChatClient(); + var chatOptions = new ChatOptions() { - ConversationId = threadId + ConversationId = threadId, + RawRepresentationFactory = _ => new ResponseCreationOptions() + { + Metadata = + { + { "entity_id", agentName } + } + }, }; await foreach (var update in openAiClient.GetStreamingResponseAsync(messages, chatOptions, cancellationToken: cancellationToken))