a2aproject / a2aproject/a2a-dotnet

[Feat]: .NET Service Discovery support

オープン
#473 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C#
スター
262
フォーク
64
平均マージ
5日 2時間
マージ済み PR(30日)
31

説明

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

I'd like to use [.NET Service Discovery](https://learn.microsoft.com/en-us/dotnet/core/extensions/service-discovery?tabs=dotnet-cli) to be able to [refer to services in .NET Aspire by their name](https://aspire.dev/fundamentals/service-discovery/) instead of having to manually configure addresses.

### Describe the solution you'd like

A2A libraries resolve service names to URLs. The following code works without crashing:

```csharp
// Initialize a resolver pointing at the remote agent's host.
A2ACardResolver itHelpdeskAgentResolver = new(new Uri("https+http://itservices-agent-api"));

// Resolve the agent card and create an AIAgent in one step.
AIAgent itHelpdeskAgent = await itHelpdeskAgentResolver.GetAIAgentAsync();
```

Reference: https://learn.microsoft.com/en-us/agent-framework/integrations/by-component/agent-services/a2a?pivots=programming-language-csharp#well-known-uri

### Describe alternatives you've considered

_No response_

### Additional context

Using the following code leads to a crash:

```csharp
// Initialize a resolver pointing at the remote agent's host.
A2ACardResolver itHelpdeskAgentResolver = new(new Uri("https+http://itservices-agent-api"));

// Resolve the agent card and create an AIAgent in one step.
AIAgent itHelpdeskAgent = await itHelpdeskAgentResolver.GetAIAgentAsync();
```

```
Unhandled exception. System.NotSupportedException: The 'https+http' scheme is not supported.
7
at System.Net.Http.SocketsHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
8
at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
9
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
10
at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
11
at A2A.A2ACardResolver.GetAgentCardAsync(CancellationToken cancellationToken)
12
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
13
at A2A.A2ACardResolver.GetAgentCardAsync(CancellationToken cancellationToken)
14
at A2A.A2ACardResolverExtensions.GetAIAgentAsync(A2ACardResolver resolver, HttpClient httpClient, A2AClientOptions options, ILoggerFactory loggerFactory, CancellationToken cancellationToken)
15
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
16
at A2A.A2ACardResolverExtensions.GetAIAgentAsync(A2ACardResolver resolver, HttpClient httpClient, A2AClientOptions options, ILoggerFactory loggerFactory, CancellationToken cancellationToken)
17
at Program.$(String[] args) in /workspaces/wsi-super-agent/backend/src/SuperAgentV2.AgentService/Program.cs:line 32
18
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
19
at Program.$(String[] args)
20
at Program.(String[] args)
21
--- End of stack trace from previous location ---
22
at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
23
at A2A.A2ACardResolver.GetAgentCardAsync(CancellationToken cancellationToken)
24
at A2A.A2ACardResolverExtensions.GetAIAgentAsync(A2ACardResolver resolver, HttpClient httpClient, A2AClientOptions options, ILoggerFactory loggerFactory, CancellationToken cancellationToken)
```

### Code of Conduct

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

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。