From 5718b7e46937c60274b524ab071285069f5c4dc9 Mon Sep 17 00:00:00 2001 From: "nick.yi" Date: Tue, 21 Apr 2026 11:13:02 +0800 Subject: [PATCH] optimize AI Context --- .../BotSharp.Core/Routing/RoutingService.InvokeAgent.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs index b2f246fb0..c00332c6a 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeAgent.cs @@ -38,13 +38,14 @@ public async Task InvokeAgent( RoleDialogModel response; var message = dialogs.Last(); + var conversationDialogs = dialogs.Where(x => x.MessageType != MessageTypeName.RecordOnly).ToList(); if (options?.UseStream == true) { - response = await chatCompletion.GetChatCompletionsStreamingAsync(agent, dialogs); + response = await chatCompletion.GetChatCompletionsStreamingAsync(agent, conversationDialogs); } else { - response = await chatCompletion.GetChatCompletions(agent, dialogs); + response = await chatCompletion.GetChatCompletions(agent, conversationDialogs); } if (response.Role == AgentRole.Function && !string.IsNullOrEmpty(response.FunctionName))