Files
agent-framework/dotnet
T
Korolev Dmitry 6ec21859cf .NET: feat: Microsoft.Extensions.AI.Agents.Hosting.A2A package (#390)
* add timeout handling for message send

* prepare a2a proj

* fix it finally

* add a holder for selected protocol

* init types ;

* see discoveredAgentCardJson

* prettify json

* correct usage

* client setup for card

* setp?

* message:send

* init task based communication

* try call it via the agent thread

* okay i got back the message wooooow!

* nit

* fix duplicates

* yea matey!

* fix knights-knaves for A2A-Task-based communication

* fix a2a agents csproj

* AI feedback

* a2a does not support netstandard / netfx

* try fix build + refactor

* bump a2a for net9 only

* rollback System.Net.ServerSentEvents & Microsoft.Bcl.AsyncInterfaces version upgrade; override in-place and retarget to net9;net8 for A2A

* address PR comments x1

* refactor a2a interfaces

* address PR comments x2

* fix cancel usage

* separate project for A2A.AspNetCore

* simplify

* cleanup

* cleanup dependencies

* generate convertor tests / fix namespaces etc

* setup actor client!

* fix build

* backoff conversations

* fix duplicate message streaming

* address PR comments x1

* remove internalsvisibleto

* dont implement agent card query on my own: give it to the user

* nit

* rename and move projects

* fix dotnet-format

* address PR comments x1

* remove unreferenced project

* rollback

* rename

* nit

---------

Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
6ec21859cf · 2025-08-25 11:14:55 +00:00
History
..

Get Started with Microsoft Agent Framework for C# Developers

Run the Minimal Console demo

The Minimal Console demo is a simple console application which shows how to create and run an agent.

Supported Platforms:

  • .Net: net9.0, net8.0, netstandard2.0, net472
  • OS: Windows, macOS, Linux

If you want to use the latest published packages following the instructions here.

1. Configure required environment variables

This samples uses Azure OpenAI by default so you need to set the following environment variable

$env:AZURE_OPENAI_ENDPOINT = "https://<your deployment>.openai.azure.com/"

If you want to use OpenAI

  1. Edit Program.cs and change the following lines:
    AIAgent agent = new AzureOpenAIClient(
      new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")!),
      new AzureCliCredential())
       .GetChatClient("gpt-4o-mini")
       .CreateAIAgent(
         instructions: "You are a helpful assistant, you can help the user with weather information.",
         tools: [AIFunctionFactory.Create(GetWeather)]);
    
    To this:
    AIAgent agent = new OpenAIClient(Environment.GetEnvironmentVariable("OPENAI_API_KEY")!)
      .GetChatClient("gpt-4o-mini")
      .CreateAIAgent(
        instructions: "You are a helpful assistant, you can help the user with weather information.",
        tools: [AIFunctionFactory.Create(GetWeather)]);
    
  2. Create an environment variable with your OpenAI key
    $env:OPENAI_API_KEY = "sk-..."
    

2. Build the project

cd demos\MinimalConsole
dotnet build

3. Run the demonstration

dotnet run --framework net9.0 --no-build

Sample output:

The weather in Amsterdam is currently cloudy, with a high temperature of 15°C.