mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
32e054f1fe
* Rename AI Agent packages to use Microsoft.Agents.AI * Fix for build * Fix formatting * Fix formatting * Ignore in VSTHRD200 in migration samples * Ignore in VSTHRD200 in migration samples * Add some missing projects and run format * Fix build errors * Address code review feedback * Fix merge issues --------- Co-authored-by: Mark Wallace <markwallace@microsoft.com>
20 lines
776 B
C#
20 lines
776 B
C#
// 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.Agents.AI;
|
|
|
|
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);
|