From 4d1b42763485a301a8233f9502b2c291ddd77d68 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 30 Dec 2025 16:06:20 +0800 Subject: [PATCH] Enhance Message Filtering in LLM Context Conversion - Added logic to skip internal message types ("tool_call", "loading", "action", "event") during LLM context conversion to prevent confusion, while retaining "error" messages for troubleshooting purposes. - Improved clarity in the handling of message types to ensure only relevant content is processed for LLM interactions. --- agent/assistant/history.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/agent/assistant/history.go b/agent/assistant/history.go index 0d70b58f..0992dad8 100644 --- a/agent/assistant/history.go +++ b/agent/assistant/history.go @@ -161,6 +161,14 @@ func (ast *Assistant) convertStoreMessageToContext(msg *storetypes.Message) *age return nil } + // Skip internal message types that should not be included in LLM context + // These types are for UI/internal use only and can confuse the LLM + // Note: "error" is kept so LLM can help troubleshoot issues + switch msg.Type { + case "tool_call", "loading", "action", "event": + return nil + } + // Extract content from Props content := ast.extractContentFromProps(msg.Props, msg.Type) if content == nil {