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;