From bfed82603351a3c586fc15d83bb31e78c1931a2b Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Sat, 21 Dec 2024 20:56:33 -0800 Subject: [PATCH] Fix gemini bug adding empty code block at end of text blocks --- src/core/Cline.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/Cline.ts b/src/core/Cline.ts index ea2492fccf..5f3f3d8dc5 100644 --- a/src/core/Cline.ts +++ b/src/core/Cline.ts @@ -934,6 +934,15 @@ export class Cline { } } } + + if (!block.partial) { + // gemini models add this artifact to the end of text content: + const TOOL_CODE_SUFFIX = "```tool_code" + if (content?.trimEnd().endsWith(TOOL_CODE_SUFFIX)) { + content = content.trimEnd().slice(0, -TOOL_CODE_SUFFIX.length) + } + } + await this.say("text", content, undefined, block.partial) break }