Skip to content

A programming framework for agentic AI

[.Net] Add a generic `IHandle` interface so AgentRuntime doesn't need to deal with typed handler (#3985)

Xiaoyun Zhang6bea055b26f2
diff --git a/dotnet/.editorconfig b/dotnet/.editorconfig
index 6e2b709d8..3821c59cc 100644
--- a/dotnet/.editorconfig
+++ b/dotnet/.editorconfig
@@ -193,10 +193,6 @@ csharp_using_directive_placement = outside_namespace:error
csharp_prefer_static_local_function = true:warning
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning
-# Header template
-file_header_template = Copyright (c) Microsoft Corporation. All rights reserved.\n{fileName}
-dotnet_diagnostic.IDE0073.severity = error
-
# enable format error
dotnet_diagnostic.IDE0055.severity = error
@@ -557,8 +553,8 @@ dotnet_diagnostic.IDE0060.severity = warning
dotnet_diagnostic.IDE0062.severity = warning
# IDE0073: File header
-dotnet_diagnostic.IDE0073.severity = suggestion
-file_header_template = Copyright (c) Microsoft. All rights reserved.
+dotnet_diagnostic.IDE0073.severity = warning
+file_header_template = Copyright (c) Microsoft Corporation. All rights reserved.\n{fileName}
# IDE1006: Required naming style
dotnet_diagnostic.IDE1006.severity = warning
diff --git a/dotnet/AutoGen.sln b/dotnet/AutoGen.sln
index 4b8ce8ff0..291cb4846 100644
--- a/dotnet/AutoGen.sln
+++ b/dotnet/AutoGen.sln
@@ -123,6 +123,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloAgent", "samples\Hello
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AIModelClientHostingExtensions", "src\Microsoft.AutoGen\Extensions\AIModelClientHostingExtensions\AIModelClientHostingExtensions.csproj", "{97550E87-48C6-4EBF-85E1-413ABAE9DBFD}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AutoGen.Agents.Tests", "Microsoft.AutoGen.Agents.Tests\Microsoft.AutoGen.Agents.Tests.csproj", "{CF4C92BD-28AE-4B8F-B173-601004AEC9BF}"
+EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{686480D7-8FEC-4ED3-9C5D-CEBE1057A7ED}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloAgentState", "samples\Hello\HelloAgentState\HelloAgentState.csproj", "{64EF61E7-00A6-4E5E-9808-62E10993A0E5}"
@@ -337,6 +339,10 @@ Global
{97550E87-48C6-4EBF-85E1-413ABAE9DBFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97550E87-48C6-4EBF-85E1-413ABAE9DBFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97550E87-48C6-4EBF-85E1-413ABAE9DBFD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CF4C92BD-28AE-4B8F-B173-601004AEC9BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CF4C92BD-28AE-4B8F-B173-601004AEC9BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CF4C92BD-28AE-4B8F-B173-601004AEC9BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CF4C92BD-28AE-4B8F-B173-601004AEC9BF}.Release|Any CPU.Build.0 = Release|Any CPU
{64EF61E7-00A6-4E5E-9808-62E10993A0E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64EF61E7-00A6-4E5E-9808-62E10993A0E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64EF61E7-00A6-4E5E-9808-62E10993A0E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -401,6 +407,7 @@ Global
{A20B9894-F352-4338-872A-F215A241D43D} = {7EB336C2-7C0A-4BC8-80C6-A3173AB8DC45}
{8F7560CF-EEBB-4333-A69F-838CA40FD85D} = {7EB336C2-7C0A-4BC8-80C6-A3173AB8DC45}
{97550E87-48C6-4EBF-85E1-413ABAE9DBFD} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}
+ {CF4C92BD-28AE-4B8F-B173-601004AEC9BF} = {F823671B-3ECA-4AE6-86DA-25E920D3FE64}
{64EF61E7-00A6-4E5E-9808-62E10993A0E5} = {7EB336C2-7C0A-4BC8-80C6-A3173AB8DC45}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
diff --git a/dotnet/Microsoft.AutoGen.Agents.Tests/AgentBaseTests.cs b/dotnet/Microsoft.AutoGen.Agents.Tests/AgentBaseTests.cs
new file mode 100644
index 000000000..4e17dd56f
--- /dev/null
+++ b/dotnet/Microsoft.AutoGen.Agents.Tests/AgentBaseTests.cs
@@ -0,0 +1,51 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AgentBaseTests.cs
+
+using FluentAssertions;
+using Google.Protobuf.Reflection;
+using Microsoft.AutoGen.Abstractions;
+using Moq;
+using Xunit;
+
+namespace Microsoft.AutoGen.Agents.Tests;
+
+public class AgentBaseTests
+{
+ [Fact]
+ public async Task ItInvokeRightHandlerTestAsync()
+ {
+ var mockContext = new Mock<IAgentContext>();
+ var agent = new TestAgent(mockContext.Object, new EventTypes(TypeRegistry.Empty, [], []));
+
+ await agent.HandleObject("hello world");
+ await agent.HandleObject(42);
+
+ agent.ReceivedItems.Should().HaveCount(2);
+ agent.ReceivedItems[0].Should().Be("hello world");
+ agent.ReceivedItems[1].Should().Be(42);
+ }
+
+ /// <summary>
+ /// The test agent is a simple agent that is used for testing purposes.
+ /// </summary>
+ public class TestAgent : AgentBase, IHandle<string>, IHandle<int>
+ {
+ public TestAgent(IAgentContext context, EventTypes eventTypes) : base(context, eventTypes)
+ {
+ }
+
+ public Task Handle(string item)
+ {
+ ReceivedItems.Add(item);
+ return Task.CompletedTask;
+ }
+
+ public Task Handle(int item)
+ {
+ ReceivedItems.Add(item);
+ return Task.CompletedTask;
+ }
+
+ public List<object> ReceivedItems { get; private set; } = [];
+ }
+}
diff --git a/dotnet/Microsoft.AutoGen.Agents.Tests/Microsoft.AutoGen.Agents.Tests.csproj b/dotnet/Microsoft.AutoGen.Agents.Tests/Microsoft.AutoGen.Agents.Tests.csproj
new file mode 100644
index 000000000..ca18cf97c
--- /dev/null
+++ b/dotnet/Microsoft.AutoGen.Agents.Tests/Microsoft.AutoGen.Agents.Tests.csproj
@@ -0,0 +1,14 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFrameworks>$(TestTargetFrameworks)</TargetFrameworks>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+ <IsTestProject>True</IsTestProject>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\src\Microsoft.AutoGen\Agents\Microsoft.AutoGen.Agents.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/dotnet/samples/AutoGen.BasicSamples/CodeSnippet/AgentCodeSnippet.cs b/dotnet/samples/AutoGen.BasicSamples/CodeSnippet/AgentCodeSnippet.cs
index 8bb9871b1..b97f30229 100644
--- a/dotnet/samples/AutoGen.BasicSamples/CodeSnippet/AgentCodeSnippet.cs
+++ b/dotnet/samples/AutoGen.BasicSamples/CodeSnippet/AgentCodeSnippet.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// AgentCodeSnippet.cs
+
using AutoGen.Core;
namespace AutoGen.BasicSample.CodeSnippet;
diff --git a/dotnet/samples/AutoGen.BasicSamples/CodeSnippet/UserProxyAgentCodeSnippet.cs b/dotnet/samples/AutoGen.BasicSamples/CodeSnippet/UserProxyAgentCodeSnippet.cs
index b34d201d2..a04685be9 100644
--- a/dotnet/samples/AutoGen.BasicSamples/CodeSnippet/UserProxyAgentCodeSnippet.cs
+++ b/dotnet/samples/AutoGen.BasicSamples/CodeSnippet/UserProxyAgentCodeSnippet.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// UserProxyAgentCodeSnippet.cs
+
using AutoGen.Core;
namespace AutoGen.BasicSample.CodeSnippet;
diff --git a/dotnet/samples/AutoGen.BasicSamples/Example06_UserProxyAgent.cs b/dotnet/samples/AutoGen.BasicSamples/Example06_UserProxyAgent.cs
index 314062dc2..655121f96 100644
--- a/dotnet/samples/AutoGen.BasicSamples/Example06_UserProxyAgent.cs
+++ b/dotnet/samples/AutoGen.BasicSamples/Example06_UserProxyAgent.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Example06_UserProxyAgent.cs
+
using AutoGen.Core;
using AutoGen.OpenAI;
using AutoGen.OpenAI.Extension;
diff --git a/dotnet/samples/AutoGen.BasicSamples/Program.cs b/dotnet/samples/AutoGen.BasicSamples/Program.cs
index 5afbd8ec1..3a2edbb58 100644
--- a/dotnet/samples/AutoGen.BasicSamples/Program.cs
+++ b/dotnet/samples/AutoGen.BasicSamples/Program.cs
@@ -1,4 +1,5 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Program.cs
//await Example07_Dynamic_GroupChat_Calculate_Fibonacci.RunAsync();
diff --git a/dotnet/samples/AutoGen.OpenAI.Sample/Connect_To_Azure_OpenAI.cs b/dotnet/samples/AutoGen.OpenAI.Sample/Connect_To_Azure_OpenAI.cs
index 0cc9fe988..f7ecbf371 100644
--- a/dotnet/samples/AutoGen.OpenAI.Sample/Connect_To_Azure_OpenAI.cs
+++ b/dotnet/samples/AutoGen.OpenAI.Sample/Connect_To_Azure_OpenAI.cs
@@ -1,4 +1,5 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Connect_To_Azure_OpenAI.cs
#region using_statement
using System.ClientModel;
diff --git a/dotnet/samples/Hello/Backend/Program.cs b/dotnet/samples/Hello/Backend/Program.cs
index 747e0d860..9f55daf69 100644
--- a/dotnet/samples/Hello/Backend/Program.cs
+++ b/dotnet/samples/Hello/Backend/Program.cs
@@ -1,4 +1,6 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Program.cs
+
using Microsoft.Extensions.Hosting;
var app = await Microsoft.AutoGen.Runtime.Host.StartAsync(local: true);
diff --git a/dotnet/samples/Hello/Hello.AppHost/Program.cs b/dotnet/samples/Hello/Hello.AppHost/Program.cs
index d7c37df8e..d9acc3ea3 100644
--- a/dotnet/samples/Hello/Hello.AppHost/Program.cs
+++ b/dotnet/samples/Hello/Hello.AppHost/Program.cs
@@ -1,4 +1,5 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Program.cs
var builder = DistributedApplication.CreateBuilder(args);
var backend = builder.AddProject<Projects.Backend>("backend");
diff --git a/dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs b/dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs
index 935d1d50b..ebde6d6d2 100644
--- a/dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs
+++ b/dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// HelloAIAgent.cs
+
using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Agents;
using Microsoft.Extensions.AI;
diff --git a/dotnet/samples/Hello/HelloAIAgents/Program.cs b/dotnet/samples/Hello/HelloAIAgents/Program.cs
index d2239f22b..9d1964bfd 100644
--- a/dotnet/samples/Hello/HelloAIAgents/Program.cs
+++ b/dotnet/samples/Hello/HelloAIAgents/Program.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Program.cs
+
using Hello;
using Microsoft.AspNetCore.Builder;
using Microsoft.AutoGen.Abstractions;
diff --git a/dotnet/samples/Hello/HelloAgent/Program.cs b/dotnet/samples/Hello/HelloAgent/Program.cs
index bccc66dfb..fbe5d2f6d 100644
--- a/dotnet/samples/Hello/HelloAgent/Program.cs
+++ b/dotnet/samples/Hello/HelloAgent/Program.cs
@@ -1,11 +1,20 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Program.cs
using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Agents;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
-// send a message to the agent
+// step 1: create in-memory agent runtime
+
+// step 2: register HelloAgent to that agent runtime
+
+// step 3: start the agent runtime
+
+// step 4: send a message to the agent
+
+// step 5: wait for the agent runtime to shutdown
var app = await AgentsApp.PublishMessageAsync("HelloAgents", new NewMessageReceived
{
Message = "World"
diff --git a/dotnet/samples/Hello/HelloAgentState/Program.cs b/dotnet/samples/Hello/HelloAgentState/Program.cs
index 6880bdd61..66b888d6c 100644
--- a/dotnet/samples/Hello/HelloAgentState/Program.cs
+++ b/dotnet/samples/Hello/HelloAgentState/Program.cs
@@ -1,4 +1,5 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Program.cs
using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Agents;
diff --git a/dotnet/samples/dev-team/DevTeam.AgentHost/Program.cs b/dotnet/samples/dev-team/DevTeam.AgentHost/Program.cs
index d5c129c3b..4864f3942 100644
--- a/dotnet/samples/dev-team/DevTeam.AgentHost/Program.cs
+++ b/dotnet/samples/dev-team/DevTeam.AgentHost/Program.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Program.cs
+
using Microsoft.AutoGen.Runtime;
var builder = WebApplication.CreateBuilder(args);
diff --git a/dotnet/samples/dev-team/DevTeam.Agents/Developer/Developer.cs b/dotnet/samples/dev-team/DevTeam.Agents/Developer/Developer.cs
index 706325182..42a1cc97d 100644
--- a/dotnet/samples/dev-team/DevTeam.Agents/Developer/Developer.cs
+++ b/dotnet/samples/dev-team/DevTeam.Agents/Developer/Developer.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Developer.cs
+
using DevTeam.Shared;
using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Agents;
diff --git a/dotnet/samples/dev-team/DevTeam.Agents/Developer/DeveloperPrompts.cs b/dotnet/samples/dev-team/DevTeam.Agents/Developer/DeveloperPrompts.cs
index 5aa8c2756..d4b5a4f94 100644
--- a/dotnet/samples/dev-team/DevTeam.Agents/Developer/DeveloperPrompts.cs
+++ b/dotnet/samples/dev-team/DevTeam.Agents/Developer/DeveloperPrompts.cs
@@ -1,3 +1,5 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// DeveloperPrompts.cs
namespace DevTeam.Agents;
public static class DeveloperSkills
diff --git a/dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLead.cs b/dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLead.cs
index a0bd80497..f66fed507 100644
--- a/dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLead.cs
+++ b/dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLead.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// DeveloperLead.cs
+
using DevTeam.Shared;
using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Agents;
diff --git a/dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLeadPrompts.cs b/dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLeadPrompts.cs
index 3ab394cdb..0aeb3b26d 100644
--- a/dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLeadPrompts.cs
+++ b/dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLeadPrompts.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// DeveloperLeadPrompts.cs
+
namespace DevTeam.Agents;
public static class DevLeadSkills
{
diff --git a/dotnet/samples/dev-team/DevTeam.Agents/ProductManager/PMPrompts.cs b/dotnet/samples/dev-team/DevTeam.Agents/ProductManager/PMPrompts.cs
index ad1c431a4..08d173b11 100644
--- a/dotnet/samples/dev-team/DevTeam.Agents/ProductManager/PMPrompts.cs
+++ b/dotnet/samples/dev-team/DevTeam.Agents/ProductManager/PMPrompts.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// PMPrompts.cs
+
namespace DevTeam.Agents;
public static class PMSkills
{
diff --git a/dotnet/samples/dev-team/DevTeam.Agents/ProductManager/ProductManager.cs b/dotnet/samples/dev-team/DevTeam.Agents/ProductManager/ProductManager.cs
index a5bdca19d..140f573c7 100644
--- a/dotnet/samples/dev-team/DevTeam.Agents/ProductManager/ProductManager.cs
+++ b/dotnet/samples/dev-team/DevTeam.Agents/ProductManager/ProductManager.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// ProductManager.cs
+
using DevTeam.Shared;
using Microsoft.AutoGen.Abstractions;
using Microsoft.AutoGen.Agents;
diff --git a/dotnet/samples/dev-team/DevTeam.Agents/Program.cs b/dotnet/samples/dev-team/DevTeam.Agents/Program.cs
index 965c23cc9..6d9937889 100644
--- a/dotnet/samples/dev-team/DevTeam.Agents/Program.cs
+++ b/dotnet/samples/dev-team/DevTeam.Agents/Program.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Program.cs
+
using DevTeam.Agents;
using Microsoft.AutoGen.Agents;
using Microsoft.AutoGen.Extensions.SemanticKernel;
diff --git a/dotnet/samples/dev-team/DevTeam.AppHost/Program.cs b/dotnet/samples/dev-team/DevTeam.AppHost/Program.cs
index 99a1978c5..99dd61a79 100644
--- a/dotnet/samples/dev-team/DevTeam.AppHost/Program.cs
+++ b/dotnet/samples/dev-team/DevTeam.AppHost/Program.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Program.cs
+
var builder = DistributedApplication.CreateBuilder(args);
builder.AddAzureProvisioning();
diff --git a/dotnet/samples/dev-team/DevTeam.Backend/Agents/AzureGenie.cs b/dotnet/samples/dev-team/DevTeam.Backend/Agents/AzureGenie.cs
index 61c618acd..258e0d1c2 100644
--- a/dotnet/samples/dev-team/DevTeam.Backend/Agents/AzureGenie.cs
+++ b/dotnet/samples/dev-team/DevTeam.Backend/Agents/AzureGenie.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AzureGenie.cs
+
using DevTeam.Backend;
using DevTeam.Shared;
using Microsoft.AutoGen.Abstractions;
diff --git a/dotnet/samples/dev-team/DevTeam.Backend/Agents/Hubber.cs b/dotnet/samples/dev-team/DevTeam.Backend/Agents/Hubber.cs
index f42eb4763..2f4c37338 100644
--- a/dotnet/samples/dev-team/DevTeam.Backend/Agents/Hubber.cs
+++ b/dotnet/samples/dev-team/DevTeam.Backend/Agents/Hubber.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Hubber.cs
+
using System.Text.Json;
using DevTeam;
using DevTeam.Backend;
diff --git a/dotnet/samples/dev-team/DevTeam.Backend/Agents/Sandbox.cs b/dotnet/samples/dev-team/DevTeam.Backend/Agents/Sandbox.cs
index 1d13c7bd2..2090ca39e 100644
--- a/dotnet/samples/dev-team/DevTeam.Backend/Agents/Sandbox.cs
+++ b/dotnet/samples/dev-team/DevTeam.Backend/Agents/Sandbox.cs
@@ -1,7 +1,5 @@
-// TODO: Reimplement using ACA Sessions
-// using DevTeam.Events;
-// using Microsoft.AutoGen.Abstractions;
-// using Microsoft.AutoGen.Agents;
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Sandbox.cs
// namespace DevTeam.Backend;
diff --git a/dotnet/samples/dev-team/DevTeam.Backend/Program.cs b/dotnet/samples/dev-team/DevTeam.Backend/Program.cs
index 9de188bdf..b24476692 100644
--- a/dotnet/samples/dev-team/DevTeam.Backend/Program.cs
+++ b/dotnet/samples/dev-team/DevTeam.Backend/Program.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Program.cs
+
using Azure.Identity;
using DevTeam.Backend;
using DevTeam.Options;
diff --git a/dotnet/samples/dev-team/DevTeam.Backend/Services/AzureService.cs b/dotnet/samples/dev-team/DevTeam.Backend/Services/AzureService.cs
index 826751065..3c3bbf07a 100644
--- a/dotnet/samples/dev-team/DevTeam.Backend/Services/AzureService.cs
+++ b/dotnet/samples/dev-team/DevTeam.Backend/Services/AzureService.cs
@@ -1,3 +1,5 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AzureService.cs
using System.Text;
using Azure;
diff --git a/dotnet/samples/dev-team/DevTeam.Backend/Services/GithubAuthService.cs b/dotnet/samples/dev-team/DevTeam.Backend/Services/GithubAuthService.cs
index 19d9e1214..d1a3bb7c0 100644
--- a/dotnet/samples/dev-team/DevTeam.Backend/Services/GithubAuthService.cs
+++ b/dotnet/samples/dev-team/DevTeam.Backend/Services/GithubAuthService.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// GithubAuthService.cs
+
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Security.Cryptography;
diff --git a/dotnet/samples/dev-team/DevTeam.Backend/Services/GithubService.cs b/dotnet/samples/dev-team/DevTeam.Backend/Services/GithubService.cs
index b1e0dcc77..5c6dc2125 100644
--- a/dotnet/samples/dev-team/DevTeam.Backend/Services/GithubService.cs
+++ b/dotnet/samples/dev-team/DevTeam.Backend/Services/GithubService.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// GithubService.cs
+
using System.Text;
using Azure.Storage.Files.Shares;
using DevTeam.Options;
diff --git a/dotnet/samples/dev-team/DevTeam.Backend/Services/GithubWebHookProcessor.cs b/dotnet/samples/dev-team/DevTeam.Backend/Services/GithubWebHookProcessor.cs
index e72b511e2..54ef97e05 100644
--- a/dotnet/samples/dev-team/DevTeam.Backend/Services/GithubWebHookProcessor.cs
+++ b/dotnet/samples/dev-team/DevTeam.Backend/Services/GithubWebHookProcessor.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// GithubWebHookProcessor.cs
+
using System.Globalization;
using DevTeam.Shared;
using Microsoft.AutoGen.Abstractions;
diff --git a/dotnet/samples/dev-team/DevTeam.Shared/EventExtensions.cs b/dotnet/samples/dev-team/DevTeam.Shared/EventExtensions.cs
index f276d294f..60c044ea9 100644
--- a/dotnet/samples/dev-team/DevTeam.Shared/EventExtensions.cs
+++ b/dotnet/samples/dev-team/DevTeam.Shared/EventExtensions.cs
@@ -1,4 +1,5 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// EventExtensions.cs
using System.Globalization;
using Microsoft.AutoGen.Abstractions;
diff --git a/dotnet/samples/dev-team/DevTeam.Shared/Models/DevPlan.cs b/dotnet/samples/dev-team/DevTeam.Shared/Models/DevPlan.cs
index 51c4ae49c..5d9bdb59a 100644
--- a/dotnet/samples/dev-team/DevTeam.Shared/Models/DevPlan.cs
+++ b/dotnet/samples/dev-team/DevTeam.Shared/Models/DevPlan.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// DevPlan.cs
+
namespace DevTeam;
public class DevLeadPlan
{
diff --git a/dotnet/samples/dev-team/DevTeam.Shared/Options/AzureOptions.cs b/dotnet/samples/dev-team/DevTeam.Shared/Options/AzureOptions.cs
index 3bdd1adf5..56499982a 100644
--- a/dotnet/samples/dev-team/DevTeam.Shared/Options/AzureOptions.cs
+++ b/dotnet/samples/dev-team/DevTeam.Shared/Options/AzureOptions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AzureOptions.cs
+
using System.ComponentModel.DataAnnotations;
namespace DevTeam.Options;
diff --git a/dotnet/samples/dev-team/DevTeam.Shared/Options/GithubOptions.cs b/dotnet/samples/dev-team/DevTeam.Shared/Options/GithubOptions.cs
index b279d8df7..0ceb2e68a 100644
--- a/dotnet/samples/dev-team/DevTeam.Shared/Options/GithubOptions.cs
+++ b/dotnet/samples/dev-team/DevTeam.Shared/Options/GithubOptions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// GithubOptions.cs
+
using System.ComponentModel.DataAnnotations;
namespace DevTeam.Options;
diff --git a/dotnet/samples/dev-team/DevTeam.Shared/ParseExtensions.cs b/dotnet/samples/dev-team/DevTeam.Shared/ParseExtensions.cs
index b6f5b5292..c4681513d 100644
--- a/dotnet/samples/dev-team/DevTeam.Shared/ParseExtensions.cs
+++ b/dotnet/samples/dev-team/DevTeam.Shared/ParseExtensions.cs
@@ -1,4 +1,5 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// ParseExtensions.cs
namespace DevTeam;
diff --git a/dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionRequest.cs b/dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionRequest.cs
index b9f5fb630..c3f378dff 100644
--- a/dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionRequest.cs
+++ b/dotnet/src/AutoGen.Anthropic/DTO/ChatCompletionRequest.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// ChatCompletionRequest.cs
+
using System.Collections.Generic;
using System.Text.Json.Serialization;
diff --git a/dotnet/src/AutoGen.Core/Extension/AgentExtension.cs b/dotnet/src/AutoGen.Core/Extension/AgentExtension.cs
index 011382502..3bc5787a8 100644
--- a/dotnet/src/AutoGen.Core/Extension/AgentExtension.cs
+++ b/dotnet/src/AutoGen.Core/Extension/AgentExtension.cs
@@ -1,4 +1,5 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AgentExtension.cs
using System;
using System.Collections.Generic;
diff --git a/dotnet/src/AutoGen.Core/GroupChat/GroupChat.cs b/dotnet/src/AutoGen.Core/GroupChat/GroupChat.cs
index 7fca2e8f4..198eb4d6f 100644
--- a/dotnet/src/AutoGen.Core/GroupChat/GroupChat.cs
+++ b/dotnet/src/AutoGen.Core/GroupChat/GroupChat.cs
@@ -1,4 +1,5 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// GroupChat.cs
using System;
using System.Collections.Generic;
diff --git a/dotnet/src/AutoGen/LMStudioConfig.cs b/dotnet/src/AutoGen/LMStudioConfig.cs
index a2c74c6d2..4605b0511 100644
--- a/dotnet/src/AutoGen/LMStudioConfig.cs
+++ b/dotnet/src/AutoGen/LMStudioConfig.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// LMStudioConfig.cs
+
using System;
using System.ClientModel;
using OpenAI;
diff --git a/dotnet/src/Microsoft.AutoGen/Abstractions/AgentId.cs b/dotnet/src/Microsoft.AutoGen/Abstractions/AgentId.cs
new file mode 100644
index 000000000..7229b7365
--- /dev/null
+++ b/dotnet/src/Microsoft.AutoGen/Abstractions/AgentId.cs
@@ -0,0 +1,13 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AgentId.cs
+
+namespace Microsoft.AutoGen.Abstractions;
+
+public partial class AgentId
+{
+ public AgentId(string type, string key)
+ {
+ Type = type;
+ Key = key;
+ }
+}
diff --git a/dotnet/src/Microsoft.AutoGen/Abstractions/ChatHistoryItem.cs b/dotnet/src/Microsoft.AutoGen/Abstractions/ChatHistoryItem.cs
index 911c13f24..0a779405e 100644
--- a/dotnet/src/Microsoft.AutoGen/Abstractions/ChatHistoryItem.cs
+++ b/dotnet/src/Microsoft.AutoGen/Abstractions/ChatHistoryItem.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// ChatHistoryItem.cs
+
namespace Microsoft.AutoGen.Abstractions;
[Serializable]
diff --git a/dotnet/src/Microsoft.AutoGen/Abstractions/ChatState.cs b/dotnet/src/Microsoft.AutoGen/Abstractions/ChatState.cs
index 8185c153d..459a17045 100644
--- a/dotnet/src/Microsoft.AutoGen/Abstractions/ChatState.cs
+++ b/dotnet/src/Microsoft.AutoGen/Abstractions/ChatState.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// ChatState.cs
+
using Google.Protobuf;
namespace Microsoft.AutoGen.Abstractions;
diff --git a/dotnet/src/Microsoft.AutoGen/Abstractions/ChatUserType.cs b/dotnet/src/Microsoft.AutoGen/Abstractions/ChatUserType.cs
index 74743fbff..4ee8dcd33 100644
--- a/dotnet/src/Microsoft.AutoGen/Abstractions/ChatUserType.cs
+++ b/dotnet/src/Microsoft.AutoGen/Abstractions/ChatUserType.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// ChatUserType.cs
+
namespace Microsoft.AutoGen.Abstractions;
public enum ChatUserType
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/IAgentBase.cs b/dotnet/src/Microsoft.AutoGen/Abstractions/IAgentBase.cs
similarity index 78%
rename from dotnet/src/Microsoft.AutoGen/Agents/IAgentBase.cs
rename to dotnet/src/Microsoft.AutoGen/Abstractions/IAgentBase.cs
index cd0f63b4f..6b4159493 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/IAgentBase.cs
+++ b/dotnet/src/Microsoft.AutoGen/Abstractions/IAgentBase.cs
@@ -1,7 +1,9 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// IAgentBase.cs
+
using Google.Protobuf;
-using Microsoft.AutoGen.Abstractions;
-namespace Microsoft.AutoGen.Agents;
+namespace Microsoft.AutoGen.Abstractions;
public interface IAgentBase
{
diff --git a/dotnet/src/Microsoft.AutoGen/Abstractions/IAgentContext.cs b/dotnet/src/Microsoft.AutoGen/Abstractions/IAgentContext.cs
new file mode 100644
index 000000000..d93b62467
--- /dev/null
+++ b/dotnet/src/Microsoft.AutoGen/Abstractions/IAgentContext.cs
@@ -0,0 +1,20 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// IAgentContext.cs
+
+using System.Diagnostics;
+using Microsoft.Extensions.Logging;
+
+namespace Microsoft.AutoGen.Abstractions;
+
+public interface IAgentContext
+{
+ AgentId AgentId { get; }
+ IAgentBase? AgentInstance { get; set; }
+ DistributedContextPropagator DistributedContextPropagator { get; } // TODO: Remove this. An abstraction should not have a dependency on DistributedContextPropagator.
+ ILogger Logger { get; } // TODO: Remove this. An abstraction should not have a dependency on ILogger.
+ ValueTask Store(AgentState value);
+ ValueTask<AgentState> Read(AgentId agentId);
+ ValueTask SendResponseAsync(RpcRequest request, RpcResponse response);
+ ValueTask SendRequestAsync(IAgentBase agent, RpcRequest request);
+ ValueTask PublishEventAsync(CloudEvent @event);
+}
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/IAgentWorkerRuntime.cs b/dotnet/src/Microsoft.AutoGen/Abstractions/IAgentWorkerRuntime.cs
similarity index 69%
rename from dotnet/src/Microsoft.AutoGen/Agents/IAgentWorkerRuntime.cs
rename to dotnet/src/Microsoft.AutoGen/Abstractions/IAgentWorkerRuntime.cs
index 5c2c7f486..1a255e132 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/IAgentWorkerRuntime.cs
+++ b/dotnet/src/Microsoft.AutoGen/Abstractions/IAgentWorkerRuntime.cs
@@ -1,8 +1,8 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// IAgentWorkerRuntime.cs
-using Microsoft.AutoGen.Abstractions;
+namespace Microsoft.AutoGen.Abstractions;
-namespace Microsoft.AutoGen.Agents;
public interface IAgentWorkerRuntime
{
ValueTask PublishEvent(CloudEvent evt);
diff --git a/dotnet/src/Microsoft.AutoGen/Abstractions/IHandle.cs b/dotnet/src/Microsoft.AutoGen/Abstractions/IHandle.cs
index 4465d8889..ff43852b1 100644
--- a/dotnet/src/Microsoft.AutoGen/Abstractions/IHandle.cs
+++ b/dotnet/src/Microsoft.AutoGen/Abstractions/IHandle.cs
@@ -1,6 +1,14 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// IHandle.cs
+
namespace Microsoft.AutoGen.Abstractions;
-public interface IHandle<T>
+public interface IHandle
+{
+ Task HandleObject(object item);
+}
+
+public interface IHandle<T> : IHandle
{
Task Handle(T item);
}
diff --git a/dotnet/src/Microsoft.AutoGen/Abstractions/MessageExtensions.cs b/dotnet/src/Microsoft.AutoGen/Abstractions/MessageExtensions.cs
index 5fa09ae21..2c8f5d053 100644
--- a/dotnet/src/Microsoft.AutoGen/Abstractions/MessageExtensions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Abstractions/MessageExtensions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// MessageExtensions.cs
+
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
diff --git a/dotnet/src/Microsoft.AutoGen/Abstractions/TopicSubscriptionAttribute.cs b/dotnet/src/Microsoft.AutoGen/Abstractions/TopicSubscriptionAttribute.cs
index 7651c78ca..79d8393d2 100644
--- a/dotnet/src/Microsoft.AutoGen/Abstractions/TopicSubscriptionAttribute.cs
+++ b/dotnet/src/Microsoft.AutoGen/Abstractions/TopicSubscriptionAttribute.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// TopicSubscriptionAttribute.cs
+
namespace Microsoft.AutoGen.Abstractions;
[AttributeUsage(AttributeTargets.All)]
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/AgentBase.cs b/dotnet/src/Microsoft.AutoGen/Agents/AgentBase.cs
index cfe2b4091..af06c84e9 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/AgentBase.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/AgentBase.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AgentBase.cs
+
using System.Diagnostics;
using System.Reflection;
using System.Text;
@@ -9,7 +12,7 @@ using Microsoft.Extensions.Logging;
namespace Microsoft.AutoGen.Agents;
-public abstract class AgentBase : IAgentBase
+public abstract class AgentBase : IAgentBase, IHandle
{
public static readonly ActivitySource s_source = new("AutoGen.Agent");
public AgentId AgentId => _context.AgentId;
@@ -251,5 +254,23 @@ public abstract class AgentBase : IAgentBase
return Task.CompletedTask;
}
- public virtual Task<RpcResponse> HandleRequest(RpcRequest request) => Task.FromResult(new RpcResponse { Error = "Not implemented" });
+ public Task<RpcResponse> HandleRequest(RpcRequest request) => Task.FromResult(new RpcResponse { Error = "Not implemented" });
+
+ public virtual Task HandleObject(object item)
+ {
+ // get all Handle<T> methods
+ var handleTMethods = this.GetType().GetMethods().Where(m => m.Name == "Handle" && m.GetParameters().Length == 1).ToList();
+
+ // get the one that matches the type of the item
+ var handleTMethod = handleTMethods.FirstOrDefault(m => m.GetParameters()[0].ParameterType == item.GetType());
+
+ // if we found one, invoke it
+ if (handleTMethod != null)
+ {
+ return (Task)handleTMethod.Invoke(this, [item])!;
+ }
+
+ // otherwise, complain
+ throw new InvalidOperationException($"No handler found for type {item.GetType().FullName}");
+ }
}
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/AgentBaseExtensions.cs b/dotnet/src/Microsoft.AutoGen/Agents/AgentBaseExtensions.cs
index 0f815e3d2..ef62a2b1d 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/AgentBaseExtensions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/AgentBaseExtensions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AgentBaseExtensions.cs
+
using System.Diagnostics;
namespace Microsoft.AutoGen.Agents;
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/AgentContext.cs b/dotnet/src/Microsoft.AutoGen/Agents/AgentContext.cs
index 30be1406d..325bc33a1 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/AgentContext.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/AgentContext.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AgentContext.cs
+
using System.Diagnostics;
using Microsoft.AutoGen.Abstractions;
using Microsoft.Extensions.Logging;
@@ -10,14 +13,14 @@ internal sealed class AgentContext(AgentId agentId, IAgentWorkerRuntime runtime,
public AgentId AgentId { get; } = agentId;
public ILogger Logger { get; } = logger;
- public AgentBase? AgentInstance { get; set; }
+ public IAgentBase? AgentInstance { get; set; }
public DistributedContextPropagator DistributedContextPropagator { get; } = distributedContextPropagator;
public async ValueTask SendResponseAsync(RpcRequest request, RpcResponse response)
{
response.RequestId = request.RequestId;
await _runtime.SendResponse(response);
}
- public async ValueTask SendRequestAsync(AgentBase agent, RpcRequest request)
+ public async ValueTask SendRequestAsync(IAgentBase agent, RpcRequest request)
{
await _runtime.SendRequest(agent, request).ConfigureAwait(false);
}
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/AgentId.cs b/dotnet/src/Microsoft.AutoGen/Agents/AgentId.cs
deleted file mode 100644
index da771c47d..000000000
--- a/dotnet/src/Microsoft.AutoGen/Agents/AgentId.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using RpcAgentId = Microsoft.AutoGen.Abstractions.AgentId;
-
-namespace Microsoft.AutoGen.Agents;
-
-public sealed record class AgentId(string Type, string Key)
-{
- public static implicit operator RpcAgentId(AgentId agentId) => new()
- {
- Type = agentId.Type,
- Key = agentId.Key
- };
-
- public static implicit operator AgentId(RpcAgentId agentId) => new(agentId.Type, agentId.Key);
- public override string ToString() => $"{Type}/{Key}";
-}
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/AgentWorker.cs b/dotnet/src/Microsoft.AutoGen/Agents/AgentWorker.cs
index 0ba909ac6..30ebda6e7 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/AgentWorker.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/AgentWorker.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AgentWorker.cs
+
using System.Diagnostics;
using Google.Protobuf;
using Microsoft.AutoGen.Abstractions;
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Agents/AIAgent/InferenceAgent.cs b/dotnet/src/Microsoft.AutoGen/Agents/Agents/AIAgent/InferenceAgent.cs
index 15c4fc095..1568d9769 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/Agents/AIAgent/InferenceAgent.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/Agents/AIAgent/InferenceAgent.cs
@@ -1,4 +1,8 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// InferenceAgent.cs
+
using Google.Protobuf;
+using Microsoft.AutoGen.Abstractions;
using Microsoft.Extensions.AI;
namespace Microsoft.AutoGen.Agents.Client;
public abstract class InferenceAgent<T> : AgentBase where T : IMessage, new()
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Agents/AIAgent/SKAiAgent.cs b/dotnet/src/Microsoft.AutoGen/Agents/Agents/AIAgent/SKAiAgent.cs
index becd2c208..ceeeadacc 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/Agents/AIAgent/SKAiAgent.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/Agents/AIAgent/SKAiAgent.cs
@@ -1,7 +1,9 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// SKAiAgent.cs
using System.Globalization;
using System.Text;
+using Microsoft.AutoGen.Abstractions;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using Microsoft.SemanticKernel.Memory;
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/ConsoleAgent.cs b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/ConsoleAgent.cs
index 2df6c7965..9470b0fb0 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/ConsoleAgent.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/ConsoleAgent.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// ConsoleAgent.cs
+
using Microsoft.AutoGen.Abstractions;
using Microsoft.Extensions.DependencyInjection;
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/IHandleConsole.cs b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/IHandleConsole.cs
index fc9ccae56..a103aa5e3 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/IHandleConsole.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/IHandleConsole.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// IHandleConsole.cs
+
using Microsoft.AutoGen.Abstractions;
namespace Microsoft.AutoGen.Agents;
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/FileAgent/FileAgent.cs b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/FileAgent/FileAgent.cs
index 2149a32d2..bcc52bba4 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/FileAgent/FileAgent.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/FileAgent/FileAgent.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// FileAgent.cs
+
using Microsoft.AutoGen.Abstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/IOAgent.cs b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/IOAgent.cs
index fc0f49733..34c9ef306 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/IOAgent.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/IOAgent.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// IOAgent.cs
+
using Microsoft.AutoGen.Abstractions;
namespace Microsoft.AutoGen.Agents;
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/WebAPIAgent/WebAPIAgent.cs b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/WebAPIAgent/WebAPIAgent.cs
index 418ef8d5a..76b57b598 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/WebAPIAgent/WebAPIAgent.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/WebAPIAgent/WebAPIAgent.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// WebAPIAgent.cs
+
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AutoGen.Abstractions;
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/App.cs b/dotnet/src/Microsoft.AutoGen/Agents/App.cs
index be5da1ac5..68c57e8d6 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/App.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/App.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// App.cs
+
using System.Diagnostics.CodeAnalysis;
using Google.Protobuf;
using Microsoft.AspNetCore.Builder;
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/GrpcAgentWorkerRuntime.cs b/dotnet/src/Microsoft.AutoGen/Agents/GrpcAgentWorkerRuntime.cs
index 3a8355166..c52509876 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/GrpcAgentWorkerRuntime.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/GrpcAgentWorkerRuntime.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// GrpcAgentWorkerRuntime.cs
+
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Reflection;
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/HostBuilderExtensions.cs b/dotnet/src/Microsoft.AutoGen/Agents/HostBuilderExtensions.cs
index 74d19042e..ea8870a51 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/HostBuilderExtensions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Agents/HostBuilderExtensions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// HostBuilderExtensions.cs
+
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/IAgentContext.cs b/dotnet/src/Microsoft.AutoGen/Agents/IAgentContext.cs
deleted file mode 100644
index 0dfa78b36..000000000
--- a/dotnet/src/Microsoft.AutoGen/Agents/IAgentContext.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System.Diagnostics;
-using Microsoft.AutoGen.Abstractions;
-using Microsoft.Extensions.Logging;
-
-namespace Microsoft.AutoGen.Agents;
-
-public interface IAgentContext
-{
- AgentId AgentId { get; }
- AgentBase? AgentInstance { get; set; }
- DistributedContextPropagator DistributedContextPropagator { get; }
- ILogger Logger { get; }
- ValueTask Store(AgentState value);
- ValueTask<AgentState> Read(AgentId agentId);
- ValueTask SendResponseAsync(RpcRequest request, RpcResponse response);
- ValueTask SendRequestAsync(AgentBase agent, RpcRequest request);
- ValueTask PublishEventAsync(CloudEvent @event);
-}
diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Microsoft.AutoGen.Agents.csproj b/dotnet/src/Microsoft.AutoGen/Agents/Microsoft.AutoGen.Agents.csproj
index 5c921fc2b..8e2c45776 100644
--- a/dotnet/src/Microsoft.AutoGen/Agents/Microsoft.AutoGen.Agents.csproj
+++ b/dotnet/src/Microsoft.AutoGen/Agents/Microsoft.AutoGen.Agents.csproj
@@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
- <ProjectReference Include="../Abstractions/Microsoft.AutoGen.Abstractions.csproj" />
+ <ProjectReference Include="..\Abstractions\Microsoft.AutoGen.Abstractions.csproj" />
<ProjectReference Include="..\Runtime\Microsoft.AutoGen.Runtime.csproj" />
</ItemGroup>
diff --git a/dotnet/src/Microsoft.AutoGen/Extensions/AIModelClientHostingExtensions/AIModelClientHostingExtensions.cs b/dotnet/src/Microsoft.AutoGen/Extensions/AIModelClientHostingExtensions/AIModelClientHostingExtensions.cs
index 9d16db45c..c3c9c1973 100644
--- a/dotnet/src/Microsoft.AutoGen/Extensions/AIModelClientHostingExtensions/AIModelClientHostingExtensions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Extensions/AIModelClientHostingExtensions/AIModelClientHostingExtensions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AIModelClientHostingExtensions.cs
+
using Microsoft.Extensions.AI;
namespace Microsoft.Extensions.Hosting;
diff --git a/dotnet/src/Microsoft.AutoGen/Extensions/AIModelClientHostingExtensions/Options/AIClientOptions.cs b/dotnet/src/Microsoft.AutoGen/Extensions/AIModelClientHostingExtensions/Options/AIClientOptions.cs
index 57d6e1a61..85e946edd 100644
--- a/dotnet/src/Microsoft.AutoGen/Extensions/AIModelClientHostingExtensions/Options/AIClientOptions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Extensions/AIModelClientHostingExtensions/Options/AIClientOptions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AIClientOptions.cs
+
using System.ComponentModel.DataAnnotations;
namespace Microsoft.Extensions.Hosting;
diff --git a/dotnet/src/Microsoft.AutoGen/Extensions/AIModelClientHostingExtensions/ServiceCollectionChatCompletionExtensions.cs b/dotnet/src/Microsoft.AutoGen/Extensions/AIModelClientHostingExtensions/ServiceCollectionChatCompletionExtensions.cs
index 9511d7e73..114562993 100644
--- a/dotnet/src/Microsoft.AutoGen/Extensions/AIModelClientHostingExtensions/ServiceCollectionChatCompletionExtensions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Extensions/AIModelClientHostingExtensions/ServiceCollectionChatCompletionExtensions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// ServiceCollectionChatCompletionExtensions.cs
+
using System.ClientModel;
using System.Data.Common;
using Azure;
diff --git a/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/CloudEventExtensions.cs b/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/CloudEventExtensions.cs
index 313a0f50f..23c2edb26 100644
--- a/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/CloudEventExtensions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/CloudEventExtensions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// CloudEventExtensions.cs
+
using Google.Protobuf;
using Google.Protobuf.WellKnownTypes;
using Microsoft.AutoGen.Abstractions;
diff --git a/dotnet/src/Microsoft.AutoGen/Extensions/SemanticKernel/Options/QdrantOptions.cs b/dotnet/src/Microsoft.AutoGen/Extensions/SemanticKernel/Options/QdrantOptions.cs
index b5f61657f..1ee150f79 100644
--- a/dotnet/src/Microsoft.AutoGen/Extensions/SemanticKernel/Options/QdrantOptions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Extensions/SemanticKernel/Options/QdrantOptions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// QdrantOptions.cs
+
using System.ComponentModel.DataAnnotations;
namespace Microsoft.AutoGen.Extensions.SemanticKernel;
diff --git a/dotnet/src/Microsoft.AutoGen/Extensions/SemanticKernel/SemanticKernelHostingExtensions.cs b/dotnet/src/Microsoft.AutoGen/Extensions/SemanticKernel/SemanticKernelHostingExtensions.cs
index 0c50b6e89..666bcc04a 100644
--- a/dotnet/src/Microsoft.AutoGen/Extensions/SemanticKernel/SemanticKernelHostingExtensions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Extensions/SemanticKernel/SemanticKernelHostingExtensions.cs
@@ -1,4 +1,5 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// SemanticKernelHostingExtensions.cs
using System.Text.Json;
using Azure.AI.OpenAI;
diff --git a/dotnet/src/Microsoft.AutoGen/Runtime/AgentWorkerHostingExtensions.cs b/dotnet/src/Microsoft.AutoGen/Runtime/AgentWorkerHostingExtensions.cs
index 447b52741..db582e051 100644
--- a/dotnet/src/Microsoft.AutoGen/Runtime/AgentWorkerHostingExtensions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Runtime/AgentWorkerHostingExtensions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AgentWorkerHostingExtensions.cs
+
using System.Diagnostics;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
diff --git a/dotnet/src/Microsoft.AutoGen/Runtime/AgentWorkerRegistryGrain.cs b/dotnet/src/Microsoft.AutoGen/Runtime/AgentWorkerRegistryGrain.cs
index c9b51813b..0e7ffa7f2 100644
--- a/dotnet/src/Microsoft.AutoGen/Runtime/AgentWorkerRegistryGrain.cs
+++ b/dotnet/src/Microsoft.AutoGen/Runtime/AgentWorkerRegistryGrain.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// AgentWorkerRegistryGrain.cs
+
using Microsoft.AutoGen.Abstractions;
namespace Microsoft.AutoGen.Runtime;
diff --git a/dotnet/src/Microsoft.AutoGen/Runtime/Host.cs b/dotnet/src/Microsoft.AutoGen/Runtime/Host.cs
index f6e9326da..73b53dd41 100644
--- a/dotnet/src/Microsoft.AutoGen/Runtime/Host.cs
+++ b/dotnet/src/Microsoft.AutoGen/Runtime/Host.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Host.cs
+
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Hosting;
diff --git a/dotnet/src/Microsoft.AutoGen/Runtime/IAgentWorkerRegistryGrain.cs b/dotnet/src/Microsoft.AutoGen/Runtime/IAgentWorkerRegistryGrain.cs
index 94d99dcaa..bda83f16f 100644
--- a/dotnet/src/Microsoft.AutoGen/Runtime/IAgentWorkerRegistryGrain.cs
+++ b/dotnet/src/Microsoft.AutoGen/Runtime/IAgentWorkerRegistryGrain.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// IAgentWorkerRegistryGrain.cs
+
using Microsoft.AutoGen.Abstractions;
namespace Microsoft.AutoGen.Runtime;
diff --git a/dotnet/src/Microsoft.AutoGen/Runtime/IWorkerAgentGrain.cs b/dotnet/src/Microsoft.AutoGen/Runtime/IWorkerAgentGrain.cs
index ce93b9a41..d28e2a8c8 100644
--- a/dotnet/src/Microsoft.AutoGen/Runtime/IWorkerAgentGrain.cs
+++ b/dotnet/src/Microsoft.AutoGen/Runtime/IWorkerAgentGrain.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// IWorkerAgentGrain.cs
+
using Microsoft.AutoGen.Abstractions;
namespace Microsoft.AutoGen.Runtime;
diff --git a/dotnet/src/Microsoft.AutoGen/Runtime/IWorkerGateway.cs b/dotnet/src/Microsoft.AutoGen/Runtime/IWorkerGateway.cs
index ec63cdcc8..54ca077de 100644
--- a/dotnet/src/Microsoft.AutoGen/Runtime/IWorkerGateway.cs
+++ b/dotnet/src/Microsoft.AutoGen/Runtime/IWorkerGateway.cs
@@ -1,3 +1,5 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// IWorkerGateway.cs
using Microsoft.AutoGen.Abstractions;
diff --git a/dotnet/src/Microsoft.AutoGen/Runtime/OrleansRuntimeHostingExtenions.cs b/dotnet/src/Microsoft.AutoGen/Runtime/OrleansRuntimeHostingExtenions.cs
index 3f980cf85..fae441e0c 100644
--- a/dotnet/src/Microsoft.AutoGen/Runtime/OrleansRuntimeHostingExtenions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Runtime/OrleansRuntimeHostingExtenions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// OrleansRuntimeHostingExtenions.cs
+
using System.Configuration;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
diff --git a/dotnet/src/Microsoft.AutoGen/Runtime/WorkerAgentGrain.cs b/dotnet/src/Microsoft.AutoGen/Runtime/WorkerAgentGrain.cs
index 3bbe7d78c..7d752d156 100644
--- a/dotnet/src/Microsoft.AutoGen/Runtime/WorkerAgentGrain.cs
+++ b/dotnet/src/Microsoft.AutoGen/Runtime/WorkerAgentGrain.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// WorkerAgentGrain.cs
+
using Microsoft.AutoGen.Abstractions;
namespace Microsoft.AutoGen.Runtime;
diff --git a/dotnet/src/Microsoft.AutoGen/Runtime/WorkerGateway.cs b/dotnet/src/Microsoft.AutoGen/Runtime/WorkerGateway.cs
index 424c5193a..cca25d36a 100644
--- a/dotnet/src/Microsoft.AutoGen/Runtime/WorkerGateway.cs
+++ b/dotnet/src/Microsoft.AutoGen/Runtime/WorkerGateway.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// WorkerGateway.cs
+
using System.Collections.Concurrent;
using Grpc.Core;
using Microsoft.AutoGen.Abstractions;
diff --git a/dotnet/src/Microsoft.AutoGen/Runtime/WorkerGatewayService.cs b/dotnet/src/Microsoft.AutoGen/Runtime/WorkerGatewayService.cs
index 8600aa5fd..b5c452785 100644
--- a/dotnet/src/Microsoft.AutoGen/Runtime/WorkerGatewayService.cs
+++ b/dotnet/src/Microsoft.AutoGen/Runtime/WorkerGatewayService.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// WorkerGatewayService.cs
+
using Grpc.Core;
using Microsoft.AutoGen.Abstractions;
diff --git a/dotnet/src/Microsoft.AutoGen/Runtime/WorkerProcessConnection.cs b/dotnet/src/Microsoft.AutoGen/Runtime/WorkerProcessConnection.cs
index bd69c7905..d998ce205 100644
--- a/dotnet/src/Microsoft.AutoGen/Runtime/WorkerProcessConnection.cs
+++ b/dotnet/src/Microsoft.AutoGen/Runtime/WorkerProcessConnection.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// WorkerProcessConnection.cs
+
using System.Threading.Channels;
using Grpc.Core;
using Microsoft.AutoGen.Abstractions;
diff --git a/dotnet/src/Microsoft.AutoGen/ServiceDefaults/Extensions.cs b/dotnet/src/Microsoft.AutoGen/ServiceDefaults/Extensions.cs
index d45caeae6..a4eccacb7 100644
--- a/dotnet/src/Microsoft.AutoGen/ServiceDefaults/Extensions.cs
+++ b/dotnet/src/Microsoft.AutoGen/ServiceDefaults/Extensions.cs
@@ -1,3 +1,6 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Extensions.cs
+
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
diff --git a/dotnet/test/AutoGen.AzureAIInference.Tests/ChatRequestMessageTests.cs b/dotnet/test/AutoGen.AzureAIInference.Tests/ChatRequestMessageTests.cs
index 0e785b5e5..3eacada41 100644
--- a/dotnet/test/AutoGen.AzureAIInference.Tests/ChatRequestMessageTests.cs
+++ b/dotnet/test/AutoGen.AzureAIInference.Tests/ChatRequestMessageTests.cs
@@ -1,4 +1,5 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// ChatRequestMessageTests.cs
using System;
using System.Collections.Generic;
diff --git a/dotnet/test/AutoGen.SemanticKernel.Tests/KernelFunctionMiddlewareTests.cs b/dotnet/test/AutoGen.SemanticKernel.Tests/KernelFunctionMiddlewareTests.cs
index 80a60421d..bc00bb228 100644
--- a/dotnet/test/AutoGen.SemanticKernel.Tests/KernelFunctionMiddlewareTests.cs
+++ b/dotnet/test/AutoGen.SemanticKernel.Tests/KernelFunctionMiddlewareTests.cs
@@ -1,4 +1,5 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// KernelFunctionMiddlewareTests.cs
using System.ClientModel;
using AutoGen.Core;
diff --git a/dotnet/test/AutoGen.SourceGenerator.Tests/FunctionCallTemplateEncodingTests.cs b/dotnet/test/AutoGen.SourceGenerator.Tests/FunctionCallTemplateEncodingTests.cs
index e82aec06d..f54271844 100644
--- a/dotnet/test/AutoGen.SourceGenerator.Tests/FunctionCallTemplateEncodingTests.cs
+++ b/dotnet/test/AutoGen.SourceGenerator.Tests/FunctionCallTemplateEncodingTests.cs
@@ -1,4 +1,5 @@
-// Copyright (c) Microsoft. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// FunctionCallTemplateEncodingTests.cs
using AutoGen.SourceGenerator.Template; // Needed for FunctionCallTemplate
using Xunit; // Needed for Fact and Assert
diff --git a/dotnet/test/AutoGen.Tests/TwoAgentTest.cs b/dotnet/test/AutoGen.Tests/TwoAgentTest.cs
index a72e08451..5537506d3 100644
--- a/dotnet/test/AutoGen.Tests/TwoAgentTest.cs
+++ b/dotnet/test/AutoGen.Tests/TwoAgentTest.cs
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// TwoAgentTest.cs
+
#pragma warning disable xUnit1013
using System;
using System.Collections.Generic;