Description
When I add the HostedImageGenerationTool, I get a NullReferenceException.
Code Sample
#!/usr/bin/env dotnet
#:sdk Microsoft.NET.Sdk
#:property OutputType=Exe
#:property TargetFramework=net10.0
#:property ImplicitUsings=enable
#:property Nullable=enable
#:property NoWarn=$(NoWarn);MEAI001;OPENAI001;MAAI001
#:property PublishAot=false
#:package Microsoft.Agents.AI.OpenAI@1.3.0
using System.ClientModel;
using System.ClientModel.Primitives;
using System.ComponentModel;
using System.Diagnostics;
using System.Text.Encodings.Web;
using System.Text.Json;
using AgentSample;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
using OpenAI;
using OpenAI.Responses;
var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set.");
var apiKey = Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY") ?? throw new InvalidOperationException("AZURE_OPENAI_API_KEY is not set.");
var deploymentName = Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT_NAME") ?? "gpt-5.5";
var openAIClient = new OpenAIClient(new ApiKeyCredential(Constants.ApiKey), new()
{
Endpoint = new(Constants.Endpoint)
});
var chatClient = openAIClient.GetResponsesClient()
.AsIChatClientWithStoredOutputDisabled(Constants.DeploymentName);
var agent = chatClient.AsAIAgent(new ChatClientAgentOptions
{
Name = "ResponseAgent",
ChatOptions = new()
{
Instructions = "You are a helpful assistant that provides concise and accurate answers to questions.",
Reasoning = new()
{
Effort = ReasoningEffort.Medium,
Output = ReasoningOutput.Summary
},
Tools = [new HostedImageGenerationTool()],
}
});
var session = await agent.CreateSessionAsync();
while (true)
{
Console.Write("Question: ");
var question = Console.ReadLine()!;
var response = await agent.RunAsync(question, session);
Console.WriteLine(response);
Console.WriteLine();
}
Error Messages / Stack Traces
System.ArgumentNullException: 'Value cannot be null. (Parameter 'value')'
at OpenAI.Argument.AssertNotNull[T](T value, String name)
at OpenAI.Responses.ImageGenerationToolOutputFileFormat..ctor(String value)
at OpenAI.Responses.ImageGenerationToolOutputFileFormat.op_Implicit(String value)
at Microsoft.Extensions.AI.OpenAIResponsesChatClient.ToResponseTool(AITool tool, ChatOptions options)
at Microsoft.Extensions.AI.OpenAIResponsesChatClient.AsCreateResponseOptions(ChatOptions options, String& openAIConversationId)
at Microsoft.Extensions.AI.OpenAIResponsesChatClient.GetResponseAsync(IEnumerable`1 messages, ChatOptions options, CancellationToken cancellationToken)
at Microsoft.Extensions.AI.ConfigureOptionsChatClient.GetResponseAsync(IEnumerable`1 messages, ChatOptions options, CancellationToken cancellationToken)
at Microsoft.Extensions.AI.FunctionInvokingChatClient.GetResponseAsync(IEnumerable`1 messages, ChatOptions options, CancellationToken cancellationToken)
at Microsoft.Agents.AI.ChatClientAgent.RunCoreAsync(IEnumerable`1 messages, AgentSession session, AgentRunOptions options, CancellationToken cancellationToken)
at Microsoft.Agents.AI.ChatClientAgent.RunCoreAsync(IEnumerable`1 messages, AgentSession session, AgentRunOptions options, CancellationToken cancellationToken)
at Program.<Main>$(String[] args) in C:\Temp\AgentSample\AgentSample\Program.cs:line 108
Package Versions
Microsoft.Agents.AI.OpenAI: 1.3.0
.NET Version
.NET 10.0.7
Description
When I add the
HostedImageGenerationTool, I get aNullReferenceException.Code Sample
Error Messages / Stack Traces
Package Versions
Microsoft.Agents.AI.OpenAI: 1.3.0
.NET Version
.NET 10.0.7