* Refactor A2A extensions to use IA2AClientFactory and add ProtocolSelection sample - Update A2AAgentCardExtensions to accept IA2AClientFactory instead of A2AClientOptions - Update A2ACardResolverExtensions to accept IA2AClientFactory - Update A2AClientExtensions to accept IA2AClientFactory - Update A2AAgent to use IA2AClientFactory for client creation - Add A2AAgent_ProtocolSelection sample demonstrating protocol selection - Add comprehensive unit tests for all changes - Update README files with new sample reference Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Reorder params: options before loggerFactory in A2A extensions Move A2AClientOptions parameter before ILoggerFactory in AsAIAgent and GetAIAgentAsync extension methods to follow the repo convention of keeping LoggerFactory and CancellationToken as the last parameters. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A2A Agent Protocol Selection
This sample demonstrates how to select the A2A protocol binding when creating an AIAgent from an A2A agent card.
A2A agents can expose multiple interfaces with different protocol bindings (e.g., HTTP+JSON, JSON-RPC). By default, AsAIAgent() prefers HTTP+JSON with JSON-RPC as a fallback. This sample shows how to use A2AClientOptions.PreferredBindings to explicitly control which protocol binding is used.
The sample:
- Connects to an A2A agent server specified in the
A2A_AGENT_HOSTenvironment variable - Configures
A2AClientOptionsto prefer the HTTP+JSON protocol binding - Creates an
AIAgentfrom the resolved agent card using the specified binding - Sends a message to the agent and displays the response
Prerequisites
Before you begin, ensure you have the following prerequisites:
- .NET 10.0 SDK or later
- An A2A agent server running and accessible via HTTP
Note: These samples need to be run against a valid A2A server. If no A2A server is available, they can be run against the echo-agent that can be spun up locally by following the guidelines at: https://github.com/a2aproject/a2a-dotnet/blob/main/samples/AgentServer/README.md
Set the following environment variable:
$env:A2A_AGENT_HOST="http://localhost:5000" # Replace with your A2A agent server host