microsoft / microsoft/agent-framework

.NET: [Bug]: Following the Aspire DevUI Readme results in `Error: CLIENT_ERROR: Agent 'agentservice' not found.`

Open
#5,781 2 comments 0 reactions 0 assignees View on GitHub
.NET bug devui reproduced
Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
2d 45m
Merged PRs (30d)
358

Description

### Description

I followed https://github.com/microsoft/agent-framework/blob/939d4d01537339ea023272c42a5a7999f4eada8a/dotnet/src/Aspire.Hosting.AgentFramework.DevUI/README.md:

- created new Aspire solution using aspire new aspire-starter
- added DevUI code and nuget package to apphost
- removed generated frontend project
- replaced generated backend project by agent service setup from Readme
- I added `Microsoft.Agents.AI.DevUI` to the AppHost project as a workaround for #5779

DevUI is correctly served now, but when sending a chat message to the agent, DevUI shows an error that it cannot find the agent service which is configured as a reference from Aspire.

### Code Sample

AppHost.cs:

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var agentService = builder.AddProject("agentservice")
.WithHttpHealthCheck("/health");

var apiKey = builder.AddParameter("github-models-key",
value: "github_pat_mysecret",
secret: true);

var openai = builder.AddOpenAI("openai")
.WithApiKey(apiKey)
.WithEndpoint("https://models.github.ai/inference");

var devui = builder.AddDevUI("devui")
.WithAgentService(agentService)
.WaitFor(agentService);

builder.Build().Run();
```

AgentService Program.cs:

```csharp
using Microsoft.Agents.AI.Hosting;

var builder = WebApplication.CreateBuilder(args);

// Add service defaults & Aspire client integrations.
builder.AddServiceDefaults();

// Add services to the container.
builder.Services.AddProblemDetails();

// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();

builder.AddOpenAIClient(connectionName: "openai");

// In the agent service's Program.cs
builder.AddAIAgent("writer", "You write short stories.");
builder.Services.AddOpenAIResponses();
builder.Services.AddOpenAIConversations();

var app = builder.Build();

app.MapOpenAIResponses();
app.MapOpenAIConversations();

// Configure the HTTP request pipeline.
app.UseExceptionHandler();

if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}

app.MapDefaultEndpoints();

app.Run();
```

### Error Messages / Stack Traces

Image

In DevUI:
> Error: CLIENT_ERROR: Agent 'agentservice' not found.

In Aspire:
```json
{
"resourceLogs": [
{
"scopeLogs": [
{
"scope": {
"name": "Microsoft.Agents.AI.Hosting.OpenAI.Responses.HostedAgentResponseExecutor"
},
"logRecords": [
{
"timeUnixNano": "1778594930358264300",
"severityNumber": 13,
"severityText": "Warning",
"body": {
"stringValue": "Failed to resolve agent with name 'agentservice'"
},
"attributes": [
{
"key": "AgentName",
"value": {
"stringValue": "agentservice"
}
},
{
"key": "ConnectionId",
"value": {
"stringValue": "0HNLG5VKSTDLF"
}
},
{
"key": "RequestId",
"value": {
"stringValue": "0HNLG5VKSTDLF:00000005"
}
},
{
"key": "RequestPath",
"value": {
"stringValue": "/v1/responses"
}
},
{
"key": "aspire.log_id",
"value": {
"stringValue": "16"
}
}
],
"flags": 1,
"traceId": "53e9c743ba33b0a17c08371ceafe5bd6",
"spanId": "6fd00178f7ac3f1d"
}
]
}
],
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "agentservice"
}
},
{
"key": "service.instance.id",
"value": {
"stringValue": "efrsgtzt"
}
},
{
"key": "telemetry.sdk.language",
"value": {
"stringValue": "dotnet"
}
},
{
"key": "telemetry.sdk.name",
"value": {
"stringValue": "opentelemetry"
}
},
{
"key": "telemetry.sdk.version",
"value": {
"stringValue": "1.15.3"
}
}
]
}
}
]
}
```

### Package Versions

- `Aspire.Hosting.AgentFramework.DevU`I: `1.5.0-preview.260507.1`
- other `Microsoft.Agents.AI.*`: `1.5.0`

### .NET Version

10.0

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the Aspire.Hosting.AgentFramework.DevUI README, then compare the AppHost.cs DevUI reference with the agent service's Program.cs registration and mapped endpoints. Reproduce the sample on .NET 10 using the listed package versions and inspect the agent-name resolution behind /v1/responses. Done means DevUI can send a chat message to the configured agent without the 'agentservice' not found error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
ai, backend, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.