Skip to content

.NET: docs(aspire-devui): align README usage example with WithAgentService semantics#5907

Open
jluocsa wants to merge 1 commit into
microsoft:mainfrom
jluocsa:fix/aspire-devui-readme-agent-name-5781
Open

.NET: docs(aspire-devui): align README usage example with WithAgentService semantics#5907
jluocsa wants to merge 1 commit into
microsoft:mainfrom
jluocsa:fix/aspire-devui-readme-agent-name-5781

Conversation

@jluocsa
Copy link
Copy Markdown

@jluocsa jluocsa commented May 17, 2026

Motivation and Context

dotnet/src/Aspire.Hosting.AgentFramework.DevUI/README.md shows an end-to-end Usage example that does not work as written. The AppHost.cs snippet registers Aspire project resources as "writer-agent" / "editor-agent" and calls WithAgentService(writerAgent) with no explicit agents: argument. As documented in the "Agent discovery" section, that defaults to declaring a single agent named after the Aspire resource (so the aggregator advertises writer-agent/writer-agent). The companion Program.cs snippet, however, registers the agent inside the service as just "writer" via AddAIAgent("writer", ...). The two halves therefore do not refer to the same agent, and running the sample fails at the first chat message with:

Error: CLIENT_ERROR: Agent 'writer-agent' not found.

This was reported in #5781 (label reproduced), with the reporter independently arriving at the same fix the existing XmlDoc on WithAgentService already recommends.

Description

Documentation-only change to dotnet/src/Aspire.Hosting.AgentFramework.DevUI/README.md.

  • Usage example: pass the explicit agents: [new("writer", ...)] / agents: [new("editor", ...)] argument to WithAgentService, matching the working code in .NET: [Bug]: Following the Aspire DevUI Readme results in Error: CLIENT_ERROR: Agent 'agentservice' not found. #5781 and the XmlDoc example in AgentFrameworkBuilderExtensions.cs. Add one short paragraph that names the relationship between the Aspire resource name (used as the entity-ID prefix) and the AgentEntityInfo.Id (must match AddAIAgent(...)), with a link to the Agent discovery section for the default behavior.
  • Agent discovery: rewrite the example so it no longer duplicates the Usage example. It now illustrates the two scenarios where the section is actually useful: (1) the convenient default when the resource name happens to match the agent name, and (2) a single service hosting multiple agents (which can only be expressed with explicit metadata).

No source-code changes. No public API or behavior changes.

Fixes #5781

Contribution Checklist

  • The code builds clean without any errors or warnings (docs-only change)
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible (N/A — README only)
  • Is this a breaking change? No.

…rvice semantics

The Usage example in dotnet/src/Aspire.Hosting.AgentFramework.DevUI/README.md
contained an AppHost.cs snippet that registered Aspire project resources as
"writer-agent" / "editor-agent" and called WithAgentService(writerAgent) with
no explicit agents argument. WithAgentService defaults to a single agent named
after the Aspire resource, so the aggregator advertised entities
"writer-agent/writer-agent" and "editor-agent/editor-agent". The companion
Program.cs snippet registered the agent inside the service as just "writer"
via AddAIAgent, so DevUI requests against the advertised entity failed with
`CLIENT_ERROR: Agent 'writer-agent' not found.`.

This change updates the Usage example to pass the explicit `agents:` argument
that the reporter (microsoft#5781) confirmed works, matching the example already shown
in the XmlDoc for WithAgentService. It also adds a short sentence explaining
the relationship between Aspire resource names and AgentEntityInfo Ids, and
links readers to the Agent discovery section for the default case.

The Agent discovery section's example is updated so it no longer duplicates
the Usage example: it now shows (a) the convenient default when resource name
matches agent name, and (b) the multi-agent-per-service shape that benefits
from explicit metadata.

No source code changes; documentation only.

Fixes microsoft#5781
Copilot AI review requested due to automatic review settings May 17, 2026 17:12
@moonbox3 moonbox3 added documentation Improvements or additions to documentation .NET labels May 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Aspire DevUI hosting README to ensure the end-to-end usage example matches WithAgentService’s default agent-discovery behavior, preventing agent-name mismatches between the AppHost and the agent service.

Changes:

  • Updates the Usage example to pass explicit agents: metadata to WithAgentService, aligning entity IDs with AddAIAgent(...) names.
  • Adds a short clarification explaining the relationship between Aspire resource names (entity ID prefix) and AgentEntityInfo.Id (agent identifier).
  • Reworks the “Agent discovery” section to demonstrate (1) the convenient default when resource name == agent name, and (2) explicit metadata for multi-agent services.

@jluocsa
Copy link
Copy Markdown
Author

jluocsa commented May 17, 2026

@microsoft-github-policy-service agree [company=Microsoft]

@jluocsa
Copy link
Copy Markdown
Author

jluocsa commented May 17, 2026

@microsoft-github-policy-service agree company=Microsoft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation .NET

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants