Skip to content

.NET: AgentCard not assigning URI when using app.MapA2A(...) #1765

@foxminchan

Description

@foxminchan

After upgrading to the latest SDK, calling app.MapA2A(RatingAgent.Name, $"/a2a/{RatingAgent.Name}", RatingAgent.AgentCard); causes a runtime failure due to an uninitialized URI in the AgentCard.

Stack trace (simplified):

System.UriFormatException: Invalid URI: The URI is empty.
  at System.Uri..ctor(String uriString)
  at A2A.A2AAgentCardExtensions.GetAIAgentAsync(AgentCard card, HttpClient httpClient, ILoggerFactory loggerFactory)
  at BookWorm.Chassis.AI.Agents.A2AClientFactory.CreateA2AAgentClient(String serviceName, String agentName, String path)
  ...

Expected behavior
The AgentCard should have its URI assigned automatically when using the one-liner app.MapA2A(...), consistent with the previous SDK behavior.

Actual behavior
AgentCard is missing its Uri property, leading to System.UriFormatException when the SDK attempts to resolve or initialize the agent client.


✅ Previously working code

var ratingAgent = app.Services.GetRequiredKeyedService<AIAgent>(RatingAgent.Name);

app.MapA2A(
    new A2AHostAgent(ratingAgent, RatingAgent.AgentCard).TaskManager!,
    $"/a2a/{RatingAgent.Name}"
);

This code successfully assigns the URI on the AgentCard and runs as expected.


❌ Current failing code

app.MapA2A(
    RatingAgent.Name,
    $"/a2a/{RatingAgent.Name}",
    RatingAgent.AgentCard
);

You can refer this PR: foxminchan/BookWorm#210

📸 Screenshot

Image

Reference:

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions