a2aproject / a2aproject/a2a-dotnet
[Feat]: Agent card should be customizable per request
- 主要语言
- C#
- 星标
- 262
- 派生
- 64
- 平均合并
- 5 天 2 小时
- 30 天内合并 PR
- 31
描述
### 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
贡献指南
调研方向
Look at the MapHttpA2A method and the AddA2AAgent registration in the aspnetcore package. Understand how the static AgentCard is currently used. The goal is to design an IAgentCard interface or a request-time callback to make the card dynamic based on URL or user. Check the v0.3 OnAgentCardQuery handler for prior art. A newcomer would need to understand the A2A protocol and the library's service registration and endpoint mapping patterns.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp
- 领域
- api, backend
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100