a2aproject / a2aproject/a2a-dotnet

[Feat]: .NET Service Discovery support

Ouverte
#473 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C#
Étoiles
262
Forks
64
Merge moyen
5 j 2 h
PR mergées (30 j)
31

Description

### 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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

The issue is about adding support for the 'https+http' URI scheme used by .NET Service Discovery. Start by examining the A2ACardResolver constructor and the HttpClient usage in the codebase, likely in the A2A.A2ACardResolver class. Look for where URI schemes are validated or where HttpClient is configured. The goal is to modify the HTTP client to handle the 'https+http' scheme, possibly by customizing the HttpClientHandler or the URI resolution logic. Check existing tests for A2ACardResolver to understand the expected behavior and add tests for the new scheme.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
csharp
Domaine
api, backend
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Active
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.