From 17c70003e81b3dad7ba7d3d9516bb836df1c4b2f Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Wed, 18 Sep 2024 19:48:47 -0400 Subject: [PATCH] Fix parsing all user generated messages in tool results --- src/ClaudeDev.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ClaudeDev.ts b/src/ClaudeDev.ts index 3681740..c5f8d8c 100644 --- a/src/ClaudeDev.ts +++ b/src/ClaudeDev.ts @@ -1637,7 +1637,7 @@ ${this.customInstructions.trim()} // TextBlockParam, ImageBlockParam, ToolUseBlockParam, and ToolResultBlockParam. // We need to apply parseMentions() to: // 1. All TextBlockParam's text (first user message with task) - // 2. ToolResultBlockParam's content/context text arrays if it contains "" (see formatToolDeniedFeedback and consecutiveMistakeCount >= 3 above, we place all user generated tool results in tags) + // 2. ToolResultBlockParam's content/context text arrays if it contains "" (see formatToolDeniedFeedback, attemptCompletion, executeCommand, and consecutiveMistakeCount >= 3) or "" (see askFollowupQuestion), we place all user generated content in these tags so they can effectively be used as markers for when we should parse mentions) Promise.all( userContent.map(async (block) => { if (block.type === "text") { @@ -1646,7 +1646,8 @@ ${this.customInstructions.trim()} text: await parseMentions(block.text, cwd, this.providerRef.deref()?.urlScraper), } } else if (block.type === "tool_result") { - if (typeof block.content === "string" && block.content.includes("")) { + const isUserMessage = (text: string) => text.includes("") || text.includes("") + if (typeof block.content === "string" && isUserMessage(block.content)) { return { ...block, content: await parseMentions(block.content, cwd, this.providerRef.deref()?.urlScraper), @@ -1654,7 +1655,7 @@ ${this.customInstructions.trim()} } else if (Array.isArray(block.content)) { const parsedContent = await Promise.all( block.content.map(async (contentBlock) => { - if (contentBlock.type === "text" && contentBlock.text.includes("")) { + if (contentBlock.type === "text" && isUserMessage(contentBlock.text)) { return { ...contentBlock, text: await parseMentions(