Skip to content

ADD .NET SDK #28

@ckpearson

Description

@ckpearson

A .NET SDK using the Microsoft.Extensions.AI libraries to bring AG-UI support to .NET.

Core features:

  • Mirrored types for all the core protocol types and events
  • An IChatClient wrapper that automatically handles emitting the relevant events
  • A simple API for producing and emitting the events as-needed
    - [ ] .NET Standard library for consumption by latest .NET and older .NET Framework code
  • Support for both frontend and backend tool calls

Nice to haves:

AbstractAgent Equivalent:

  • Idiomatic C#, likely through use of System.Threading.Channels or IAsyncEnumerable<BaseEvent> rather than taking a dependency on something like Reactive Extensions
  • IChatClient input which handles the core lifecycle and text message lifecycle events semi-automatically with escape hatches for customisation
  • Event-driven reactivity to re-entrant tool results from the frontend (e.g. frontend calls tool, provides result in subsequent run, this provides a clean mechanism for responding to that)

ASP.NET Core Middleware

Middleware for registering agents as first-class citizens and hooking them in as endpoints automatically.

builder.Services.AddAGUIAgents()
  .RegisterAgent<DataAgent>("data", "Data Agent", "Agent with access and tooling for working with the data");

var app = builder.Build();

app.UseAGUIAgents("/agents");

Should result in the ability to POST to http://{url}/agents/{data} to be completely up and running.

Auto-Proxy Agent

Given the very common scenario of an agent needing to be a simple proxy over a call to an LLM with additional available tools / context, provide a rapid path to success:

public sealed record MyAgentState
{
   public ImmutableList<string> Messages { get; init; } = [];
}

public sealed class MyAgent : SimpleAgent<MyAgentState>
{
  protected override ValueTask PrepareTools(AgentTools tools)
  {
     /* Filter and inspect the tools passed via the frontend */
     foreach(var frontendTool in tools.Frontend)
     {
       if (frontendTool.Name == "SomeToolWeDoNotWant") {
         tools.MarkForRemoval(frontendTool);
       }
     }

     /* Register tools for the backend */
     tools.Backend.Add(AiFunctionFactory.Create(MyBackendMethod));
  }

  protected override ValueTask OnRunStart()
  {
     /* ... */
     this.Context.UpdateState(state => state with {
       Messages = [.. state.Messages, "This is a new message"]
     });
  }
}

SemanticKernel integration

Need to investigate how best to integrate with SemanticKernel and their agent approach.

Metadata

Metadata

Assignees

Labels

RoadmapThis feature or functionality should be added to the roadmap.

Type

No type

Projects

Status

In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions