Language

A2ACardResolverExtensions.GetAIAgentAsync Method

Definition

Overloads

GetAIAgentAsync(A2ACardResolver, HttpClient, A2AClientOptions, ILoggerFactory, CancellationToken)

Retrieves an instance of AIAgent for an existing A2A agent.

public static System.Threading.Tasks.Task<Microsoft.Agents.AI.AIAgent> GetAIAgentAsync(this A2A.A2ACardResolver resolver, System.Net.Http.HttpClient? httpClient = default, A2A.A2AClientOptions? options = default, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory = default, System.Threading.CancellationToken cancellationToken = default);
static member GetAIAgentAsync : A2A.A2ACardResolver * System.Net.Http.HttpClient * A2A.A2AClientOptions * Microsoft.Extensions.Logging.ILoggerFactory * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Agents.AI.AIAgent>
<Extension()>
Public Function GetAIAgentAsync (resolver As A2ACardResolver, Optional httpClient As HttpClient = Nothing, Optional options As A2AClientOptions = Nothing, Optional loggerFactory As ILoggerFactory = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of AIAgent)

Parameters

resolver
A2A.A2ACardResolver

The A2A.A2ACardResolver to use for the agent creation.

httpClient
HttpClient

The HttpClient to use for HTTP requests.

options
A2A.A2AClientOptions

Optional A2A.A2AClientOptions controlling protocol binding preference. When not provided, defaults to preferring HTTP+JSON first, with JSON-RPC as fallback.

loggerFactory
ILoggerFactory

The logger factory for enabling logging within the agent.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

An AIAgent instance backed by the A2A agent.

Remarks

This method can be used to access A2A agents that support the Well-Known URI discovery mechanism.

Applies to

GetAIAgentAsync(A2ACardResolver, A2AAgentOptions, HttpClient, A2AClientOptions, ILoggerFactory, CancellationToken)

Retrieves an instance of AIAgent for an existing A2A agent.

public static System.Threading.Tasks.Task<Microsoft.Agents.AI.AIAgent> GetAIAgentAsync(this A2A.A2ACardResolver resolver, Microsoft.Agents.AI.A2A.A2AAgentOptions agentOptions, System.Net.Http.HttpClient? httpClient = default, A2A.A2AClientOptions? clientOptions = default, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory = default, System.Threading.CancellationToken cancellationToken = default);
static member GetAIAgentAsync : A2A.A2ACardResolver * Microsoft.Agents.AI.A2A.A2AAgentOptions * System.Net.Http.HttpClient * A2A.A2AClientOptions * Microsoft.Extensions.Logging.ILoggerFactory * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.Agents.AI.AIAgent>
<Extension()>
Public Function GetAIAgentAsync (resolver As A2ACardResolver, agentOptions As A2AAgentOptions, Optional httpClient As HttpClient = Nothing, Optional clientOptions As A2AClientOptions = Nothing, Optional loggerFactory As ILoggerFactory = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of AIAgent)

Parameters

resolver
A2A.A2ACardResolver

The A2A.A2ACardResolver to use for the agent creation.

agentOptions
A2AAgentOptions

Configuration options that control the agent's identity. When provided, non-null values override the corresponding values from the resolved agent card.

httpClient
HttpClient

The HttpClient to use for HTTP requests made by the created A2A client. This is not used for fetching the agent card; the resolver uses its own configured client for that.

clientOptions
A2A.A2AClientOptions

Optional A2A.A2AClientOptions controlling protocol binding preference. When not provided, defaults to preferring HTTP+JSON first, with JSON-RPC as fallback.

loggerFactory
ILoggerFactory

The logger factory for enabling logging within the agent.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

An AIAgent instance backed by the A2A agent.

Remarks

This method can be used to access A2A agents that support the Well-Known URI discovery mechanism. When agentOptions is provided, any non-null values override the corresponding values from the resolved A2A.AgentCard.

Applies to