diff --git a/src/Infrastructure/BotSharp.Core/Plugins/PluginLoader.cs b/src/Infrastructure/BotSharp.Core/Plugins/PluginLoader.cs index 06ebd0a6b..72d55b45a 100644 --- a/src/Infrastructure/BotSharp.Core/Plugins/PluginLoader.cs +++ b/src/Infrastructure/BotSharp.Core/Plugins/PluginLoader.cs @@ -145,7 +145,8 @@ public PluginDef UpdatePluginStatus(IServiceProvider services, string id, bool e if (enable) { var dependentPlugins = new HashSet(); - FindPluginDependency(id, enable, ref dependentPlugins); + var dependentAgentIds = new HashSet(); + FindPluginDependency(id, enable, ref dependentPlugins, ref dependentAgentIds); var missingPlugins = dependentPlugins.Where(x => !config.EnabledPlugins.Contains(x)).ToList(); if (!missingPlugins.IsNullOrEmpty()) { @@ -155,7 +156,7 @@ public PluginDef UpdatePluginStatus(IServiceProvider services, string id, bool e // enable agents var agentService = services.GetRequiredService(); - foreach (var agentId in plugin.AgentIds) + foreach (var agentId in dependentAgentIds) { var agent = agentService.LoadAgent(agentId).Result; agent.Disabled = false; @@ -189,7 +190,7 @@ public PluginDef UpdatePluginStatus(IServiceProvider services, string id, bool e return plugin; } - private void FindPluginDependency(string pluginId, bool enabled, ref HashSet dependentPlugins) + private void FindPluginDependency(string pluginId, bool enabled, ref HashSet dependentPlugins, ref HashSet dependentAgentIds) { var pluginDef = _plugins.FirstOrDefault(x => x.Id == pluginId); if (pluginDef == null) return; @@ -198,6 +199,13 @@ private void FindPluginDependency(string pluginId, bool enabled, ref HashSet x.Id == pluginId); @@ -213,7 +221,7 @@ private void FindPluginDependency(string pluginId, bool enabled, ref HashSet