A programming framework for agentic AI
Simplify publish events in agent (#4093)
Diego Colombo621b17ebbe46
diff --git a/dotnet/AutoGen.sln b/dotnet/AutoGen.slnindex 4f82713b5..8557f1784 100644--- a/dotnet/AutoGen.sln+++ b/dotnet/AutoGen.sln@@ -84,8 +84,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.AbstractiEndProjectProject("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.Extensions.SemanticKernel", "src\Microsoft.AutoGen\Extensions\SemanticKernel\Microsoft.AutoGen.Extensions.SemanticKernel.csproj", "{952827D4-8D4C-4327-AE4D-E8D25811EF35}"EndProject-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.Extensions.CloudEvents", "src\Microsoft.AutoGen\Extensions\CloudEvents\Microsoft.AutoGen.Extensions.CloudEvents.csproj", "{21C9EC49-E848-4EAE-932F-0862D44F7A80}"-EndProjectProject("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.Runtime", "src\Microsoft.AutoGen\Runtime\Microsoft.AutoGen.Runtime.csproj", "{A905E29A-7110-497F-ADC5-2CE2A148FEA0}"EndProjectProject("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AutoGen.ServiceDefaults", "src\Microsoft.AutoGen\ServiceDefaults\Microsoft.AutoGen.ServiceDefaults.csproj", "{D7E9D90B-5595-4E72-A90A-6DE20D9AB7AE}"@@ -266,10 +264,6 @@ Global{952827D4-8D4C-4327-AE4D-E8D25811EF35}.Debug|Any CPU.Build.0 = Debug|Any CPU{952827D4-8D4C-4327-AE4D-E8D25811EF35}.Release|Any CPU.ActiveCfg = Release|Any CPU{952827D4-8D4C-4327-AE4D-E8D25811EF35}.Release|Any CPU.Build.0 = Release|Any CPU- {21C9EC49-E848-4EAE-932F-0862D44F7A80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU- {21C9EC49-E848-4EAE-932F-0862D44F7A80}.Debug|Any CPU.Build.0 = Debug|Any CPU- {21C9EC49-E848-4EAE-932F-0862D44F7A80}.Release|Any CPU.ActiveCfg = Release|Any CPU- {21C9EC49-E848-4EAE-932F-0862D44F7A80}.Release|Any CPU.Build.0 = Release|Any CPU{A905E29A-7110-497F-ADC5-2CE2A148FEA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU{A905E29A-7110-497F-ADC5-2CE2A148FEA0}.Debug|Any CPU.Build.0 = Debug|Any CPU{A905E29A-7110-497F-ADC5-2CE2A148FEA0}.Release|Any CPU.ActiveCfg = Release|Any CPU@@ -391,7 +385,6 @@ Global{FD87BD33-4616-460B-AC85-A412BA08BB78} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}{E0C991D9-0DB8-471C-ADC9-5FB16E2A0106} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}{952827D4-8D4C-4327-AE4D-E8D25811EF35} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}- {21C9EC49-E848-4EAE-932F-0862D44F7A80} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}{A905E29A-7110-497F-ADC5-2CE2A148FEA0} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}{D7E9D90B-5595-4E72-A90A-6DE20D9AB7AE} = {18BF8DD7-0585-48BF-8F97-AD333080CE06}{668726B9-77BC-45CF-B576-0F0773BF1615} = {686480D7-8FEC-4ED3-9C5D-CEBE1057A7ED}diff --git a/dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs b/dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.csindex f7939da7d..fd3c517f3 100644--- a/dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs+++ b/dotnet/samples/Hello/HelloAIAgents/HelloAIAgent.cs@@ -20,16 +20,10 @@ public class HelloAIAgent({var prompt = "Please write a limerick greeting someone with the name " + item.Message;var response = await client.CompleteAsync(prompt);- var evt = new Output- {- Message = response.Message.Text- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt).ConfigureAwait(false);- var goodbye = new ConversationClosed- {- UserId = this.AgentId.Key,- UserMessage = "Goodbye"- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(goodbye).ConfigureAwait(false);+ var evt = new Output { Message = response.Message.Text };+ await PublishMessageAsync(evt).ConfigureAwait(false);++ var goodbye = new ConversationClosed { UserId = this.AgentId.Key, UserMessage = "Goodbye" };+ await PublishMessageAsync(goodbye).ConfigureAwait(false);}}diff --git a/dotnet/samples/Hello/HelloAIAgents/Program.cs b/dotnet/samples/Hello/HelloAIAgents/Program.csindex ebede82bb..8285e0800 100644--- a/dotnet/samples/Hello/HelloAIAgents/Program.cs+++ b/dotnet/samples/Hello/HelloAIAgents/Program.cs@@ -46,14 +46,14 @@ namespace Hellovar evt = new Output{Message = response- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt).ConfigureAwait(false);+ };+ await PublishMessageAsync(evt).ConfigureAwait(false);var goodbye = new ConversationClosed{UserId = this.AgentId.Key,UserMessage = "Goodbye"- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(goodbye).ConfigureAwait(false);+ };+ await PublishMessageAsync(goodbye).ConfigureAwait(false);}public async Task Handle(ConversationClosed item){@@ -61,8 +61,8 @@ namespace Hellovar evt = new Output{Message = goodbye- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt).ConfigureAwait(false);+ };+ await PublishMessageAsync(evt).ConfigureAwait(false);//sleep30 secondsawait Task.Delay(30000).ConfigureAwait(false);await AgentsApp.ShutdownAsync().ConfigureAwait(false);diff --git a/dotnet/samples/Hello/HelloAgent/Program.cs b/dotnet/samples/Hello/HelloAgent/Program.csindex 02ad838de..4e96c7f99 100644--- a/dotnet/samples/Hello/HelloAgent/Program.cs+++ b/dotnet/samples/Hello/HelloAgent/Program.cs@@ -37,17 +37,14 @@ namespace Hellopublic async Task Handle(NewMessageReceived item){var response = await SayHello(item.Message).ConfigureAwait(false);- var evt = new Output- {- Message = response- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt).ConfigureAwait(false);+ var evt = new Output { Message = response };+ await PublishMessageAsync(evt).ConfigureAwait(false);var goodbye = new ConversationClosed{UserId = this.AgentId.Key,UserMessage = "Goodbye"- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(goodbye).ConfigureAwait(false);+ };+ await PublishMessageAsync(goodbye).ConfigureAwait(false);}public async Task Handle(ConversationClosed item){@@ -55,8 +52,8 @@ namespace Hellovar evt = new Output{Message = goodbye- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt).ConfigureAwait(false);+ };+ await PublishMessageAsync(evt).ConfigureAwait(false);// Signal shutdown.hostApplicationLifetime.StopApplication();diff --git a/dotnet/samples/Hello/HelloAgentState/Program.cs b/dotnet/samples/Hello/HelloAgentState/Program.csindex c1e00e4d6..d02112685 100644--- a/dotnet/samples/Hello/HelloAgentState/Program.cs+++ b/dotnet/samples/Hello/HelloAgentState/Program.cs@@ -31,20 +31,20 @@ namespace Hellovar evt = new Output{Message = response- }.ToCloudEvent(this.AgentId.Key);+ };var entry = "We said hello to " + item.Message;await Store(new AgentState{AgentId = this.AgentId,TextData = entry}).ConfigureAwait(false);- await PublishEvent(evt).ConfigureAwait(false);+ await PublishMessageAsync(evt).ConfigureAwait(false);var goodbye = new ConversationClosed{UserId = this.AgentId.Key,UserMessage = "Goodbye"- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(goodbye).ConfigureAwait(false);+ };+ await PublishMessageAsync(goodbye).ConfigureAwait(false);}public async Task Handle(ConversationClosed item){@@ -54,8 +54,8 @@ namespace Hellovar evt = new Output{Message = goodbye- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt).ConfigureAwait(false);+ };+ await PublishMessageAsync(evt).ConfigureAwait(false);//sleepawait Task.Delay(10000).ConfigureAwait(false);await AgentsApp.ShutdownAsync().ConfigureAwait(false);diff --git a/dotnet/samples/dev-team/DevTeam.Agents/Developer/Developer.cs b/dotnet/samples/dev-team/DevTeam.Agents/Developer/Developer.csindex 42a1cc97d..5b6682248 100644--- a/dotnet/samples/dev-team/DevTeam.Agents/Developer/Developer.cs+++ b/dotnet/samples/dev-team/DevTeam.Agents/Developer/Developer.cs@@ -24,8 +24,8 @@ public class Dev(IAgentContext context, Kernel kernel, ISemanticTextMemory memorRepo = item.Repo,IssueNumber = item.IssueNumber,Code = code- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public async Task Handle(CodeChainClosed item)@@ -35,8 +35,8 @@ public class Dev(IAgentContext context, Kernel kernel, ISemanticTextMemory memorvar evt = new CodeCreated{Code = lastCode- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public async Task<string> GenerateCode(string ask)diff --git a/dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLead.cs b/dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLead.csindex f66fed507..71301dd3d 100644--- a/dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLead.cs+++ b/dotnet/samples/dev-team/DevTeam.Agents/DeveloperLead/DeveloperLead.cs@@ -25,8 +25,8 @@ public class DeveloperLead(IAgentContext context, Kernel kernel, ISemanticTextMeRepo = item.Repo,IssueNumber = item.IssueNumber,Plan = plan- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public async Task Handle(DevPlanChainClosed item)@@ -36,8 +36,8 @@ public class DeveloperLead(IAgentContext context, Kernel kernel, ISemanticTextMevar evt = new DevPlanCreated{Plan = lastPlan- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public async Task<string> CreatePlan(string ask){diff --git a/dotnet/samples/dev-team/DevTeam.Agents/ProductManager/ProductManager.cs b/dotnet/samples/dev-team/DevTeam.Agents/ProductManager/ProductManager.csindex 140f573c7..a97b33356 100644--- a/dotnet/samples/dev-team/DevTeam.Agents/ProductManager/ProductManager.cs+++ b/dotnet/samples/dev-team/DevTeam.Agents/ProductManager/ProductManager.cs@@ -22,8 +22,8 @@ public class ProductManager(IAgentContext context, Kernel kernel, ISemanticTextMvar evt = new ReadmeCreated{Readme = lastReadme- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public async Task Handle(ReadmeRequested item)@@ -35,8 +35,8 @@ public class ProductManager(IAgentContext context, Kernel kernel, ISemanticTextMOrg = item.Org,Repo = item.Repo,IssueNumber = item.IssueNumber- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public async Task<string> CreateReadme(string ask)diff --git a/dotnet/samples/dev-team/DevTeam.Backend/Agents/AzureGenie.cs b/dotnet/samples/dev-team/DevTeam.Backend/Agents/AzureGenie.csindex 258e0d1c2..7dac8163a 100644--- a/dotnet/samples/dev-team/DevTeam.Backend/Agents/AzureGenie.cs+++ b/dotnet/samples/dev-team/DevTeam.Backend/Agents/AzureGenie.cs@@ -20,7 +20,7 @@ public class AzureGenie(IAgentContext context, Kernel kernel, ISemanticTextMemor// TODO: Not sure we need to store the files if we use ACA Sessions// //var data = item.ToData();// // await Store(data["org"], data["repo"], data.TryParseLong("parentNumber"), data.TryParseLong("issueNumber"), "readme", "md", "output", data["readme"]);- // await PublishEvent(new Event+ // await PublishEventAsync(new Event// {// Namespace = item.Namespace,// Type = nameof(EventTypes.ReadmeStored),@@ -36,7 +36,7 @@ public class AzureGenie(IAgentContext context, Kernel kernel, ISemanticTextMemor// //var data = item.ToData();// // await Store(data["org"], data["repo"], data.TryParseLong("parentNumber"), data.TryParseLong("issueNumber"), "run", "sh", "output", data["code"]);// // await RunInSandbox(data["org"], data["repo"], data.TryParseLong("parentNumber"), data.TryParseLong("issueNumber"));- // await PublishEvent(new Event+ // await PublishEventAsync(new Event// {// Namespace = item.Namespace,// Type = nameof(EventTypes.SandboxRunCreated),diff --git a/dotnet/samples/dev-team/DevTeam.Backend/Agents/Sandbox.cs b/dotnet/samples/dev-team/DevTeam.Backend/Agents/Sandbox.csindex 2090ca39e..306ebc945 100644--- a/dotnet/samples/dev-team/DevTeam.Backend/Agents/Sandbox.cs+++ b/dotnet/samples/dev-team/DevTeam.Backend/Agents/Sandbox.cs@@ -50,7 +50,7 @@// if (await _azService.IsSandboxCompleted(sandboxId))// {// await _azService.DeleteSandbox(sandboxId);-// await PublishEvent(new Event+// await PublishEventAsync(new Event// {// Namespace = this.GetPrimaryKeyString(),// Type = nameof(GithubFlowEventType.SandboxRunFinished),diff --git a/dotnet/src/Microsoft.AutoGen/Abstractions/IAgentBase.cs b/dotnet/src/Microsoft.AutoGen/Abstractions/IAgentBase.csindex 6b4159493..2e767e721 100644--- a/dotnet/src/Microsoft.AutoGen/Abstractions/IAgentBase.cs+++ b/dotnet/src/Microsoft.AutoGen/Abstractions/IAgentBase.cs@@ -17,5 +17,5 @@ public interface IAgentBasevoid ReceiveMessage(Message message);Task Store(AgentState state);Task<T> Read<T>(AgentId agentId) where T : IMessage, new();- ValueTask PublishEvent(CloudEvent item);+ ValueTask PublishEventAsync(CloudEvent item, CancellationToken token = default);}diff --git a/dotnet/src/Microsoft.AutoGen/Agents/AgentBase.cs b/dotnet/src/Microsoft.AutoGen/Agents/AgentBase.csindex baa7ee201..3932e007b 100644--- a/dotnet/src/Microsoft.AutoGen/Agents/AgentBase.cs+++ b/dotnet/src/Microsoft.AutoGen/Agents/AgentBase.cs@@ -197,9 +197,16 @@ public abstract class AgentBase : IAgentBase, IHandlereturn await completion.Task.ConfigureAwait(false);}- public async ValueTask PublishEvent(CloudEvent item)+ public async ValueTask PublishMessageAsync<T>(T message, string? source = null, CancellationToken token = default) where T : IMessage{- var activity = s_source.StartActivity($"PublishEvent '{item.Type}'", ActivityKind.Client, Activity.Current?.Context ?? default);+ var src = string.IsNullOrWhiteSpace(source) ? this.AgentId.Key : source;+ var evt = message.ToCloudEvent(src);+ await PublishEventAsync(evt, token).ConfigureAwait(false);+ }++ public async ValueTask PublishEventAsync(CloudEvent item, CancellationToken token = default)+ {+ var activity = s_source.StartActivity($"PublishEventAsync '{item.Type}'", ActivityKind.Client, Activity.Current?.Context ?? default);activity?.SetTag("peer.service", $"{item.Type}/{item.Source}");// TODO: fix activitydiff --git a/dotnet/src/Microsoft.AutoGen/Agents/AgentWorker.cs b/dotnet/src/Microsoft.AutoGen/Agents/AgentWorker.csindex 30ebda6e7..a82065609 100644--- a/dotnet/src/Microsoft.AutoGen/Agents/AgentWorker.cs+++ b/dotnet/src/Microsoft.AutoGen/Agents/AgentWorker.cs@@ -12,7 +12,7 @@ public sealed class AgentWorker(IAgentWorkerRuntime runtime, DistributedContextP[FromKeyedServices("EventTypes")] EventTypes eventTypes, ILogger<AgentBase> logger): AgentBase(new AgentContext(new AgentId("client", Guid.NewGuid().ToString()), runtime, logger, distributedContextPropagator), eventTypes){- public async ValueTask PublishEventAsync(CloudEvent evt) => await PublishEvent(evt);+ public async ValueTask PublishEventAsync(CloudEvent evt) => await base.PublishEventAsync(evt);public async ValueTask PublishEventAsync(string topic, IMessage evt){diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/ConsoleAgent.cs b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/ConsoleAgent.csindex 9470b0fb0..d7c32c247 100644--- a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/ConsoleAgent.cs+++ b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/ConsoleAgent.cs@@ -27,8 +27,8 @@ public abstract class ConsoleAgent : IOAgent,var evt = new InputProcessed{Route = _route- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public override async Task Handle(Output item)@@ -40,8 +40,8 @@ public abstract class ConsoleAgent : IOAgent,var evt = new OutputWritten{Route = _route- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public override Task<string> ProcessInput(string message)diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/IHandleConsole.cs b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/IHandleConsole.csindex a103aa5e3..60df58e92 100644--- a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/IHandleConsole.cs+++ b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/ConsoleAgent/IHandleConsole.cs@@ -1,6 +1,7 @@// Copyright (c) Microsoft Corporation. All rights reserved.// IHandleConsole.cs+using Google.Protobuf;using Microsoft.AutoGen.Abstractions;namespace Microsoft.AutoGen.Agents;@@ -9,7 +10,7 @@ public interface IHandleConsole : IHandle<Output>, IHandle<Input>{string Route { get; }AgentId AgentId { get; }- ValueTask PublishEvent(CloudEvent item);+ ValueTask PublishMessageAsync<T>(T message, string? source = null, CancellationToken token = default) where T : IMessage;async Task IHandle<Output>.Handle(Output item){@@ -20,8 +21,8 @@ public interface IHandleConsole : IHandle<Output>, IHandle<Input>var evt = new OutputWritten{Route = "console"- }.ToCloudEvent(AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}async Task IHandle<Input>.Handle(Input item){@@ -33,8 +34,8 @@ public interface IHandleConsole : IHandle<Output>, IHandle<Input>var evt = new InputProcessed{Route = "console"- }.ToCloudEvent(AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}static Task ProcessOutput(string message){diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/FileAgent/FileAgent.cs b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/FileAgent/FileAgent.csindex bcc52bba4..217c2e56e 100644--- a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/FileAgent/FileAgent.cs+++ b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/FileAgent/FileAgent.cs@@ -29,8 +29,8 @@ public abstract class FileAgent(var err = new IOError{Message = errorMessage- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(err);+ };+ await PublishMessageAsync(err);return;}string content;@@ -42,8 +42,8 @@ public abstract class FileAgent(var evt = new InputProcessed{Route = _route- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public override async Task Handle(Output item){@@ -54,16 +54,16 @@ public abstract class FileAgent(var evt = new OutputWritten{Route = _route- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public override async Task<string> ProcessInput(string message){var evt = new InputProcessed{Route = _route,- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);return message;}public override Task ProcessOutput(string message)diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/IOAgent.cs b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/IOAgent.csindex 34c9ef306..6d470b345 100644--- a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/IOAgent.cs+++ b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/IOAgent.cs@@ -17,8 +17,8 @@ public abstract class IOAgent : AgentBasevar evt = new InputProcessed{Route = _route- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public virtual async Task Handle(Output item)@@ -26,8 +26,8 @@ public abstract class IOAgent : AgentBasevar evt = new OutputWritten{Route = _route- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public abstract Task ProcessInput(string message);diff --git a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/WebAPIAgent/WebAPIAgent.cs b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/WebAPIAgent/WebAPIAgent.csindex 76b57b598..69b8d177b 100644--- a/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/WebAPIAgent/WebAPIAgent.cs+++ b/dotnet/src/Microsoft.AutoGen/Agents/Agents/IOAgent/WebAPIAgent/WebAPIAgent.cs@@ -61,8 +61,8 @@ public abstract class WebAPIAgent : IOAgent,var evt = new InputProcessed{Route = _route- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public override async Task Handle(Output item)@@ -71,8 +71,8 @@ public abstract class WebAPIAgent : IOAgent,var evt = new OutputWritten{Route = _route- }.ToCloudEvent(this.AgentId.Key);- await PublishEvent(evt);+ };+ await PublishMessageAsync(evt);}public override Task<string> ProcessInput(string message)diff --git a/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/CloudEventExtensions.cs b/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/CloudEventExtensions.csdeleted file mode 100644index 23c2edb26..000000000--- a/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/CloudEventExtensions.cs+++ /dev/null@@ -1,30 +0,0 @@-// Copyright (c) Microsoft Corporation. All rights reserved.-// CloudEventExtensions.cs--using Google.Protobuf;-using Google.Protobuf.WellKnownTypes;-using Microsoft.AutoGen.Abstractions;--namespace Microsoft.AutoGen.Runtime;--public static class CloudEventExtensions--{- public static CloudEvent ToCloudEvent<T>(this T message, string source) where T : IMessage- {- return new CloudEvent- {- ProtoData = Any.Pack(message),- Type = message.Descriptor.FullName,- Source = source,- Id = Guid.NewGuid().ToString()-- };- }-- public static T FromCloudEvent<T>(this CloudEvent cloudEvent) where T : IMessage, new()- {- return cloudEvent.ProtoData.Unpack<T>();- }-}-diff --git a/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/Microsoft.AutoGen.Extensions.CloudEvents.csproj b/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/Microsoft.AutoGen.Extensions.CloudEvents.csprojdeleted file mode 100644index 45186a670..000000000--- a/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/Microsoft.AutoGen.Extensions.CloudEvents.csproj+++ /dev/null@@ -1,17 +0,0 @@-<Project Sdk="Microsoft.NET.Sdk">-- <ItemGroup>- <ProjectReference Include="../../Agents/Microsoft.AutoGen.Agents.csproj" />- </ItemGroup>-- <PropertyGroup>- <TargetFramework>net8.0</TargetFramework>- <ImplicitUsings>enable</ImplicitUsings>- <Nullable>enable</Nullable>- </PropertyGroup>-- <ItemGroup>- <PackageReference Include="Google.Protobuf" />- </ItemGroup>--</Project>diff --git a/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/Protos/states.proto b/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/Protos/states.protodeleted file mode 100644index 315a9c614..000000000--- a/dotnet/src/Microsoft.AutoGen/Extensions/CloudEvents/Protos/states.proto+++ /dev/null@@ -1,9 +0,0 @@-syntax = "proto3";--package devteam;--option csharp_namespace = "Microsoft.AutoGen.Extensions.CloudEvents";--message CloudEventsState {- string cloudevent = 1;-}