microsoft / microsoft/aspire

Aspire Agent Awarness

Open
#17,752 2 comments 0 reactions 0 assignees View on GitHub
ai triage:bot-seen
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

## Background and Motivation

Agents can use different protocols (reposnses, a2a, invocations, ...). Right now we make aspire aware of foundry prompt and hosted agents, and that ties deeply with how the agent gets deployed as well.

We could add a generic API that tells aspire a certain resource is an agent that support certain protocols, so that we can add the custom command to interact with that agent from the dashboard.

This would not influence deployment at all (you could deploy to aca, app service, etc), just enrich the resource at dashboard level. Could also be used for #13851

We could also handle some nuances for specific protocols, e.g. A2A could have custom url for the agent card in the dashboard and expose a custom env var `_AGENTCARD_URL` so that clients don't have to build it.
Also, in the A2A scenario aspire could inject the url the app is running on to the resource itself, so that the agent card could set the url to that environment variable. All clients calling an A2A agent use the url advertised in the card. That is usually hardcoded, causing issues at deployment time (you should know ahead of the time the production url and hardcode it in the card).

## Proposed API

```csharp
namespace Aspire.Hosting.Agents;

public static class AgentsResourceBuilderExtension
{
public static IResourceBuilder AsAgent(this IResourceBuilder builder, params AgentProtocol[] protocols,
string? agentCustomPath = null)
where T : IResourceWithEndpoints, IResourceWithEnvironment, IComputeResource;
}
```

## Usage Examples

```csharp
var weatherAgent = builder.AddUvicornApp("weatheragent", "./weather-agent-python", "weather_agent_python.main:app")
.WithUv()
.WithReference(deployment).WaitFor(deployment)
.AsAgent(AgentProtocol.A2A);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.