From 025e6053a65e1e09c202c4fd5f39f485636d848a Mon Sep 17 00:00:00 2001 From: Roo Code Date: Wed, 20 Aug 2025 08:52:56 +0000 Subject: [PATCH] fix: prevent API error messages from polluting chat history Remove error message from API conversation history when assistant provides no response. Keep error display to user via say("error") but do not add to LLM context. This fixes the issue where API errors disrupt conversation flow. Fixes #7249 --- src/core/task/Task.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 34f3218236..6f41b04112 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -2132,10 +2132,9 @@ export class Task extends EventEmitter implements TaskLike { "Unexpected API Response: The language model did not provide any assistant messages. This may indicate an issue with the API or the model's output.", ) - await this.addToApiConversationHistory({ - role: "assistant", - content: [{ type: "text", text: "Failure: I did not provide a response." }], - }) + // Don't add error messages to the API conversation history as it pollutes + // the context sent to the LLM. The error is already shown to the user via say("error"). + // This prevents the issue where API errors disrupt the conversation flow. } // If we reach here without continuing, return false (will always be false for now)