.NET: A2A agent (#520)

* add a2a agent

* Update dotnet/src/Microsoft.Extensions.AI.Agents.A2A/A2AAgent.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* address pr review feedback

* move unit tests for extension methods to the extensions folder

* address pr review comments

* address pr review comments

* address pr review feedback

* move a2a agent sample to console app

* remove unnecessary Ids set for new projects in the solution file

* remove unnecessary configuration

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
SergeyMenshykh
2025-09-01 08:30:30 +00:00
committed by GitHub
co-authored by Copilot
parent 97d72c967f
commit 1d2f833122
30 changed files with 1656 additions and 1 deletions
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft. All rights reserved.
// This sample shows how to create and use a simple AI agent with an existing A2A agent.
using System;
using A2A;
using Microsoft.Extensions.AI.Agents;
using Microsoft.Extensions.AI.Agents.A2A;
var a2aAgentHost = Environment.GetEnvironmentVariable("A2A_AGENT_HOST") ?? throw new InvalidOperationException("A2A_AGENT_HOST is not set.");
// Initialize an A2ACardResolver to get an A2A agent card.
A2ACardResolver agentCardResolver = new(new Uri(a2aAgentHost));
// Create an instance of the AIAgent for an existing A2A agent specified by the agent card.
AIAgent agent = await agentCardResolver.GetAIAgentAsync();
// Invoke the agent and output the text result.
AgentRunResponse response = await agent.RunAsync("Tell me a joke about a pirate.");
Console.WriteLine(response);