a2aproject / a2aproject/a2a-dotnet

[Feat]: Agent card should be customizable per request

Aperta
#353 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C#
Stelle
262
Fork
64
Merge medio
5g 2h
PR unite (30g)
31

Descrizione

### Is your feature request related to a problem? Please describe.

TLDR: Allow agent cards to by dynamic instead of a static agent card being registered on `.AddA2AAgent`.

Currently in the aspnetcore package, when you call `IServiceCollection.AddA2AAgent`, `WebApplication.MapA2A`, and `WebApplication.MapHttpA2A`, you need to provide an agent card.

This is an issue for servers that can host multiple agents and the agent changes depending on the url (and potentially other information like the current user).

Right now I can get by with:
- `IServiceCollection.AddA2AAgent` - Here I can just pass `new AgentCard()` and no issues here.
- `WebApplication.MapA2A` - This method also has an overload where you can pass in an `IA2ARequestHandler` which does not require an `AgentCard`, so we are good here.
- `WebApplication.MapHttpA2A` - This method does not have the overload like the jsonrpc method. For now we are just telling our customers that the `v1/card` operation will return an empty agent card and they should just call the `./well-known/agent-card.json` endpoint instead.

Note that we also aren't using the library's `WebApplication.MapWellKnownAgentCard`, since it uses the same static agent card that was registered on `.AddA2AAgent`, we implemented our own well known agent card endpoint.

BTW, I believe we were able to provide our own agent card on v0.3 of this library because the previous version of this library had a `.OnAgentCardQuery` handler on the task manager which allowed us to return the agent card at the time of request. Would like to have similar functionality carried over, or maybe the interface solution I mention below.

### Describe the solution you'd like

Possibly an `IAgentCard` interface that allows the developer to return an agent card in their own way will be best.

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.