From ab3d987f0c91533a1c818a538e6f2ce6ae4621c2 Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Fri, 4 Oct 2024 07:06:34 -0400 Subject: [PATCH] Handle model putting param on one line --- src/core/ClaudeDev.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/core/ClaudeDev.ts b/src/core/ClaudeDev.ts index 6ad2aa6..b5b691e 100644 --- a/src/core/ClaudeDev.ts +++ b/src/core/ClaudeDev.ts @@ -1563,7 +1563,29 @@ export class ClaudeDev { } if (currentToolUse && !currentParamName) { - // current tool doesn't have a param match yet, it's likely partial so ignore + // Even though system prompt instructs to put tags on separate lines, sometimes model outputs small non-file params on single lines (have not seen this happen with a tool use tag though) + // E.g. file + // We're making some assumptions here, like if we do match then the entire param will be on this line. + + // Try to match a parameter tag with content, even if the closing tag is missing or partial + // matches and rest of line as paramContent + const paramMatch = trimmed.match(/^<(\w+)>(.*)$/) + if (paramMatch) { + const paramName = paramMatch[1] as ToolParamName + let paramContent = paramMatch[2] + + // Remove any closing tag or partial closing tag from paramContent + // replaces any sequence that starts with