Skip to content

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

@hansmbakker

Description

@hansmbakker

Description

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

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:

var builder = DistributedApplication.CreateBuilder(args);

var agentService = builder.AddProject<Projects.Handoff_AgentService>("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:

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:

{
  "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.DevUI: 1.5.0-preview.260507.1
  • other Microsoft.Agents.AI.*: 1.5.0

.NET Version

10.0

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions