based this sample.
https://github.com/microsoft-foundry/foundry-samples/tree/main/samples/csharp/hosted-agents/agent-framework/simple-agent
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>SimpleAgent</RootNamespace>
<AssemblyName>simple-agent</AssemblyName>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);NU1903;NU1605</NoWarn>
<UserSecretsId>61a81a17-2b41-40be-a519-da32c302b7a0</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Agents.AI.Foundry.Hosting" Version="1.10.0-preview.260610.1" />
<PackageReference Include="Azure.AI.Projects" Version="2.1.0-beta.1" />
<PackageReference Include="DotNetEnv" Version="3.1.1" />
</ItemGroup>
</Project>
// Copyright (c) Microsoft. All rights reserved.
using Azure.AI.AgentServer.Core;
using Azure.AI.Projects;
using Azure.Identity;
using DotNetEnv;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Foundry.Hosting;
Env.TraversePath().Load();
var projectEndpoint = new Uri(Environment.GetEnvironmentVariable("FOUNDRY_PROJECT_ENDPOINT")
?? throw new InvalidOperationException("FOUNDRY_PROJECT_ENDPOINT environment variable is not set."));
var deployment = Environment.GetEnvironmentVariable("AZURE_AI_MODEL_DEPLOYMENT_NAME") ?? "gpt-4o";
AIAgent agent = new AIProjectClient(projectEndpoint, new DefaultAzureCredential())
.AsAIAgent(
model: deployment,
instructions: """
You are a helpful AI assistant hosted as a Foundry Hosted Agent.
You can help with a wide range of tasks including answering questions,
providing explanations, brainstorming ideas, and offering guidance.
Be concise, clear, and helpful in your responses.
""",
name: "simple-agent",
description: "A simple general-purpose AI assistant");
var builder = AgentHost.CreateBuilder(args);
builder.Services.AddFoundryResponses(agent);
builder.RegisterProtocol("responses", endpoints => endpoints.MapFoundryResponses());
var app = builder.Build();
app.Run();
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://localhost:8088/agentdev/version - - -
info: Azure.AI.AgentServer.Core.Internal.InboundRequestLoggingMiddleware[1689694937]
Inbound GET /agentdev/version starting (x-request-id: , x-ms-client-request-id: , trace-id: af83ce6b76f1d3f6e884e3d7e14c2e9a)
warn: Azure.AI.AgentServer.Core.Internal.InboundRequestLoggingMiddleware[601900377]
Inbound GET /agentdev/version failed HTTP 404 in 0ms (x-request-id: , x-ms-client-request-id: , trace-id: af83ce6b76f1d3f6e884e3d7e14c2e9a)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 GET http://localhost:8088/agentdev/version - 404 0 - 0.5652ms
info: Microsoft.AspNetCore.Hosting.Diagnostics[16]
Request reached the end of the middleware pipeline without being handled by application code. Request path: GET http://localhost:8088/agentdev/version, Response status code: 404
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 POST http://localhost:8088/responses - application/json 169
info: Azure.AI.AgentServer.Core.Internal.InboundRequestLoggingMiddleware[1689694937]
Inbound POST /responses starting (x-request-id: , x-ms-client-request-id: , trace-id: 3cdba48ca9f8c96364ed02edab0fe352)
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'HTTP: POST /responses'
info: Azure.AI.AgentServer.Responses.Internal.ResponseEndpointHandler[0]
Creating response caresp_5180c2681e20c9e200t5EuoxZiuGLfYOkcoq2KkqqjSSOmWCMr: Streaming=True Background=False Store=True Model= ConversationId=20d742b4-dcc3-4c29-acaa-c70d9ad163ab PreviousResponseId=(null) HasUserIsolationKey=False HasChatIsolationKey=False
info: Azure.AI.AgentServer.Responses.Internal.ResponseEndpointHandler[0]
SSE stream started for response caresp_5180c2681e20c9e200t5EuoxZiuGLfYOkcoq2KkqqjSSOmWCMr
info: Azure.AI.AgentServer.Responses.Internal.ResponseOrchestrator[0]
Invoking handler AgentFrameworkResponseHandler for response caresp_5180c2681e20c9e200t5EuoxZiuGLfYOkcoq2KkqqjSSOmWCMr
fail: Azure.AI.AgentServer.Responses.Internal.ResponseOrchestrator[0]
Handler failed for response caresp_5180c2681e20c9e200t5EuoxZiuGLfYOkcoq2KkqqjSSOmWCMr
System.InvalidOperationException: The registered HostedSessionIsolationKeyProvider returned null for the current request. Ensure the Foundry platform is providing the x-agent-user-isolation-key and x-agent-chat-isolation-key headers, or register a custom provider that supplies fallback values for local development.
at Microsoft.Agents.AI.Foundry.Hosting.AgentFrameworkResponseHandler.CreateAsync(CreateResponse request, ResponseContext context, CancellationToken cancellationToken)+MoveNext()
at Microsoft.Agents.AI.Foundry.Hosting.AgentFrameworkResponseHandler.CreateAsync(CreateResponse request, ResponseContext context, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at Azure.AI.AgentServer.Responses.Internal.ResponseOrchestrator.ProcessEventsAsync(CreateResponse request, ResponseExecution execution, ResponseContext context, IAsyncObserver`1 publisher, CancellationToken ct)+MoveNext()
at Azure.AI.AgentServer.Responses.Internal.ResponseOrchestrator.ProcessEventsAsync(CreateResponse request, ResponseExecution execution, ResponseContext context, IAsyncObserver`1 publisher, CancellationToken ct)+MoveNext()
at Azure.AI.AgentServer.Responses.Internal.ResponseOrchestrator.ProcessEventsAsync(CreateResponse request, ResponseExecution execution, ResponseContext context, IAsyncObserver`1 publisher, CancellationToken ct)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at Azure.AI.AgentServer.Responses.Internal.ResponseOrchestrator.CreateStreamingAsync(CreateResponse request, ResponseExecution execution, ResponseContext context, CancellationToken ct)+MoveNext()
warn: Azure.AI.AgentServer.Responses.Internal.ResponseEndpointHandler[0]
SSE stream error for response caresp_5180c2681e20c9e200t5EuoxZiuGLfYOkcoq2KkqqjSSOmWCMr
Azure.AI.AgentServer.Responses.ResponsesApiException: An internal server error occurred.
at Azure.AI.AgentServer.Responses.Internal.ResponseOrchestrator.ThrowIfPreCreatedFailure(ResponseExecution execution)
at Azure.AI.AgentServer.Responses.Internal.ResponseOrchestrator.CreateStreamingAsync(CreateResponse request, ResponseExecution execution, ResponseContext context, CancellationToken ct)+MoveNext()
at Azure.AI.AgentServer.Responses.Internal.ResponseOrchestrator.CreateStreamingAsync(CreateResponse request, ResponseExecution execution, ResponseContext context, CancellationToken ct)+MoveNext()
at Azure.AI.AgentServer.Responses.Internal.ResponseOrchestrator.CreateStreamingAsync(CreateResponse request, ResponseExecution execution, ResponseContext context, CancellationToken ct)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
at Azure.AI.AgentServer.Responses.Internal.SseResult.ExecuteAsync(HttpContext httpContext)
at Azure.AI.AgentServer.Responses.Internal.SseResult.ExecuteAsync(HttpContext httpContext)
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint 'HTTP: POST /responses'
info: Azure.AI.AgentServer.Core.Internal.InboundRequestLoggingMiddleware[194824245]
Inbound POST /responses completed HTTP 200 in 5ms (x-request-id: , x-ms-client-request-id: , trace-id: 3cdba48ca9f8c96364ed02edab0fe352)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 POST http://localhost:8088/responses - 200 - text/event-stream;+charset=utf-8 5.7099ms
Description
Simple agent sample is not working using Microsoft.Agents.AI.Foundry.Hosting 1.10.0-preview.260610.1.
Code Sample
Error Messages / Stack Traces
Package Versions
Microsoft.Agents.AI.Foundry.Hosting: 1.10.0-preview.260610.1
.NET Version
.NET 10
Additional Context
Same error occurred from
1.6.2-preview.260521.1to1.10.0-preview.260610.1.