Skip to content

A programming framework for agentic AI

add subscriptions to host builder

Jack Gerrits2ba773222003
diff --git a/dotnet/src/Microsoft.AutoGen/Core/PythonEquiv/AgentRuntimeExtensions.cs b/dotnet/src/Microsoft.AutoGen/Core/PythonEquiv/AgentRuntimeExtensions.cs
index caee18a43..4b3858c78 100644
--- a/dotnet/src/Microsoft.AutoGen/Core/PythonEquiv/AgentRuntimeExtensions.cs
+++ b/dotnet/src/Microsoft.AutoGen/Core/PythonEquiv/AgentRuntimeExtensions.cs
@@ -69,7 +69,7 @@ public static class AgentRuntimeExtensions
return subscriptions.ToArray();
}
- public static async ValueTask RegisterImplicitAgentSubscriptionsAsync<TAgent>(this IAgentRuntime runtime, AgentType type) where TAgent : IHostableAgent
+ public static async ValueTask RegisterImplicitAgentSubscriptionsAsync<TAgent>(this IAgentRuntime runtime, AgentType type, bool skipClassSubscriptions = false, bool skipDirectMessageSubscription = false) where TAgent : IHostableAgent
{
var subscriptions = BindSubscriptionsForAgentType<TAgent>(type);
foreach (var subscription in subscriptions)
diff --git a/dotnet/src/Microsoft.AutoGen/Core/PythonEquiv/AgentsApp.cs b/dotnet/src/Microsoft.AutoGen/Core/PythonEquiv/AgentsApp.cs
index 4c238078a..1a383e3df 100644
--- a/dotnet/src/Microsoft.AutoGen/Core/PythonEquiv/AgentsApp.cs
+++ b/dotnet/src/Microsoft.AutoGen/Core/PythonEquiv/AgentsApp.cs
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
-// App.cs
+// AgentsApp.cs
using Microsoft.AutoGen.Contracts.Python;
using Microsoft.Extensions.DependencyInjection;
@@ -18,13 +18,13 @@ public class AgentsAppBuilder
this.builder = baseBuilder ?? new HostApplicationBuilder();
}
- public void AddAgent<TAgent>(string name, bool registerDefaultTopics = true) where TAgent : IHostableAgent
+ public void AddAgent<TAgent>(string name, bool skipClassSubscriptions = false, bool skipDirectMessageSubscription = false) where TAgent : IHostableAgent
{
- this.AgentTypeRegistrations.Add(app => app.AgentRuntime.RegisterAgentTypeAsync<TAgent>(name, app.Services));
- if (registerDefaultTopics)
- {
- //TODO: this.AgentTypeRegistrations.Add(app => app.AgentRuntime.RegisterDefaultTopicsAsync<TAgent>(name));
- }
+ this.AgentTypeRegistrations.Add(async app => {
+ var agentType = await app.AgentRuntime.RegisterAgentTypeAsync<TAgent>(name, app.Services);
+ await app.AgentRuntime.RegisterImplicitAgentSubscriptionsAsync<TAgent>(name, skipClassSubscriptions, skipDirectMessageSubscription);
+ return agentType;
+ });
}
public async ValueTask<AgentsApp> BuildAsync()