diff --git a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs index ba739dac..59ce88c2 100644 --- a/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs +++ b/src/Infrastructure/BotSharp.Core/Conversations/Services/ConversationService.SendMessage.cs @@ -40,10 +40,10 @@ public partial class ConversationService routing.Context.Push(agent.Id, reason: "request started"); // Save payload in order to assign the payload before hook is invoked - // if (replyMessage != null && !string.IsNullOrEmpty(replyMessage.Payload)) - // { - // message.Payload = replyMessage.Payload; - // } + if (replyMessage != null && !string.IsNullOrEmpty(replyMessage.Payload)) + { + message.Payload = replyMessage.Payload; + } // Before chat completion hook hooks = ReOrderConversationHooks(hooks); diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.GetConversationContent.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.GetConversationContent.cs index f8efab46..60e81bbe 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.GetConversationContent.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.GetConversationContent.cs @@ -16,7 +16,15 @@ public partial class RoutingService role = agent.Name; } - conversation += $"{role}: {dialog.Payload ?? dialog.Content}\r\n"; + if (role == AgentRole.User) + { + conversation += $"{role}: {dialog.Payload ?? dialog.Content}\r\n"; + } + else + { + // Assistant reply doesn't need help with payload + conversation += $"{role}: {dialog.Content}\r\n"; + } } return conversation; diff --git a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs index 499c8981..64b96136 100644 --- a/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs +++ b/src/Infrastructure/BotSharp.Core/Routing/RoutingService.InvokeFunction.cs @@ -53,7 +53,8 @@ public partial class RoutingService message.PostbackFunctionName = clonedMessage.PostbackFunctionName; message.CurrentAgentId = clonedMessage.CurrentAgentId; message.Content = clonedMessage.Content; - message.Payload = clonedMessage.Payload; + // Don't copy payload + // message.Payload = clonedMessage.Payload; message.StopCompletion = clonedMessage.StopCompletion; message.RichContent = clonedMessage.RichContent; message.Data = clonedMessage.Data; diff --git a/src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/Chat/ChatCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/Chat/ChatCompletionProvider.cs index b77a47c1..3384e3b7 100644 --- a/src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/Chat/ChatCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.AzureOpenAI/Providers/Chat/ChatCompletionProvider.cs @@ -312,7 +312,7 @@ public class ChatCompletionProvider : IChatCompletion } else if (message.Role == AgentRole.Assistant) { - messages.Add(new AssistantChatMessage(message.Payload ?? message.Content)); + messages.Add(new AssistantChatMessage(message.Content)); } } diff --git a/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Chat/ChatCompletionProvider.cs b/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Chat/ChatCompletionProvider.cs index 1c9ca641..50151513 100644 --- a/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Chat/ChatCompletionProvider.cs +++ b/src/Plugins/BotSharp.Plugin.OpenAI/Providers/Chat/ChatCompletionProvider.cs @@ -290,7 +290,7 @@ public class ChatCompletionProvider : IChatCompletion } else if (message.Role == AgentRole.Assistant) { - messages.Add(new AssistantChatMessage(message.Payload ?? message.Content)); + messages.Add(new AssistantChatMessage(message.Content)); } }