From c95b20d6d4427816065712c8136585780311292f Mon Sep 17 00:00:00 2001 From: Petr Mironychev <9195189+Palm1r@users.noreply.github.com> Date: Tue, 21 Oct 2025 00:27:47 +0200 Subject: [PATCH] fix: Override file edit tool another assistant message --- ChatView/ChatModel.cpp | 4 ++++ ChatView/ClientInterface.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ChatView/ChatModel.cpp b/ChatView/ChatModel.cpp index 806249c..932d711 100644 --- a/ChatView/ChatModel.cpp +++ b/ChatView/ChatModel.cpp @@ -195,6 +195,10 @@ QJsonArray ChatModel::prepareMessagesForRequest(const QString &systemPrompt) con case ChatRole::Assistant: role = "assistant"; break; + case ChatRole::Tool: + case ChatRole::FileEdit: + // Skip Tool and FileEdit messages - they are UI-only + continue; default: continue; } diff --git a/ChatView/ClientInterface.cpp b/ChatView/ClientInterface.cpp index 8782fbd..72ff35f 100644 --- a/ChatView/ClientInterface.cpp +++ b/ChatView/ClientInterface.cpp @@ -142,6 +142,10 @@ void ClientInterface::sendMessage( QVector messages; for (const auto &msg : m_chatModel->getChatHistory()) { + // Skip Tool and FileEdit messages - they are UI-only and should not be in API history + if (msg.role == ChatModel::ChatRole::Tool || msg.role == ChatModel::ChatRole::FileEdit) { + continue; + } messages.append({msg.role == ChatModel::ChatRole::User ? "user" : "assistant", msg.content}); } context.history = messages;