From 8d8fd758d934952f4f980b7b10ae71401d8f5a1a Mon Sep 17 00:00:00 2001 From: "songguo.zeng" Date: Thu, 12 Dec 2024 18:02:00 +0800 Subject: [PATCH] AII-400 --- .../Agents/AgentHookBase.cs | 5 ----- .../BotSharp.Abstraction/Agents/IAgentHook.cs | 2 -- .../Agents/Services/AgentService.LoadAgent.cs | 21 +------------------ 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/AgentHookBase.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/AgentHookBase.cs index f4d30523..a3746ca8 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/AgentHookBase.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/AgentHookBase.cs @@ -56,9 +56,4 @@ public abstract class AgentHookBase : IAgentHook public virtual void OnAgentUtilityLoaded(Agent agent) { } - - public virtual void OnAgentLoadFilter(Agent agent) - { - - } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentHook.cs b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentHook.cs index a329134b..a3f53fb6 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentHook.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Agents/IAgentHook.cs @@ -33,6 +33,4 @@ public interface IAgentHook /// /// void OnAgentLoaded(Agent agent); - - void OnAgentLoadFilter(Agent agent); } diff --git a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.LoadAgent.cs b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.LoadAgent.cs index 3ae49385..0e9c2e3c 100644 --- a/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.LoadAgent.cs +++ b/src/Infrastructure/BotSharp.Core/Agents/Services/AgentService.LoadAgent.cs @@ -7,6 +7,7 @@ public partial class AgentService { public static ConcurrentDictionary> AgentParameterTypes = new(); + [MemoryCache(10 * 60, perInstanceCache: true)] public async Task LoadAgent(string id) { if (string.IsNullOrEmpty(id) || id == Guid.Empty.ToString()) @@ -14,26 +15,6 @@ public partial class AgentService return null; } - Agent agent = await GetLoadAgent(id); - OnAgentLoadFilter(agent); - return agent; - } - - private void OnAgentLoadFilter(Agent? agent) - { - if (agent != null && agent.Type == AgentType.Routing) - { - var hooks = _services.GetServices(); - foreach (var hook in hooks) - { - hook.OnAgentLoadFilter(agent); - } - } - } - - [MemoryCache(10 * 60, perInstanceCache: true)] - private async Task GetLoadAgent(string id) - { var hooks = _services.GetServices(); // Before agent is loaded.