Address bug when agent rawrepresentation is a MEAI type and returns it with null RawRep (#1054)

This commit is contained in:
Roger Barreto
2025-10-01 10:37:12 +00:00
committed by GitHub
parent ef88b51dd9
commit f9a3918916
3 changed files with 4 additions and 3 deletions
@@ -85,7 +85,7 @@ Console.WriteLine("""
""");
var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT environment variable is not set.");
var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? "gpt-4o-mini";
var deploymentName = System.Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? "gpt-4o-mini";
// Log application startup
appLogger.LogInformation("OpenTelemetry Aspire Demo application started");
@@ -85,7 +85,7 @@ public sealed class OpenTelemetryAgent : DelegatingAIAgent, IDisposable
var response = await this._otelClient.GetResponseAsync(messages, co, cancellationToken).ConfigureAwait(false);
return (AgentRunResponse)response.RawRepresentation!;
return response.RawRepresentation as AgentRunResponse ?? new AgentRunResponse(response);
}
/// <inheritdoc/>
@@ -96,7 +96,7 @@ public sealed class OpenTelemetryAgent : DelegatingAIAgent, IDisposable
await foreach (var update in this._otelClient.GetStreamingResponseAsync(messages, co, cancellationToken).ConfigureAwait(false))
{
yield return (AgentRunResponseUpdate)update.RawRepresentation!;
yield return update.RawRepresentation as AgentRunResponseUpdate ?? new AgentRunResponseUpdate(update);
}
}
@@ -7,6 +7,7 @@ using System.Collections;
using SystemEnvironment = System.Environment;
namespace SampleHelpers;
internal static class SampleEnvironment
{
public static string? GetEnvironmentVariable(string key)