fix: prevent file path corruption in tool execution

- Remove incorrect removeClosingTag calls from execute methods in tools
- removeClosingTag should only be used in handlePartial for streaming
- Fixes issue where paths ending with "str" were corrupted
- Fixed in WriteToFileTool, GenerateImageTool, and accessMcpResourceTool

This addresses the broader tool usage issue reported in #9239 and #9298
where incorrect usage of removeClosingTag was causing path corruption
and tool failures across multiple models.
This commit is contained in:
Roo Code 2025-11-16 09:58:04 +00:00
parent 7a06902dd8
commit b470bb0aa4
3 changed files with 6 additions and 6 deletions

View file

@ -139,12 +139,12 @@ export class GenerateImageTool extends BaseTool<"generate_image"> {
const selectedModel = state?.openRouterImageGenerationSelectedModel || IMAGE_GENERATION_MODELS[0]
const fullPath = path.resolve(task.cwd, removeClosingTag("path", relPath))
const fullPath = path.resolve(task.cwd, relPath)
const isOutsideWorkspace = isPathOutsideWorkspace(fullPath)
const sharedMessageProps = {
tool: "generateImage" as const,
path: getReadablePath(task.cwd, removeClosingTag("path", relPath)),
path: getReadablePath(task.cwd, relPath),
content: prompt,
isOutsideWorkspace,
isProtected: isWriteProtected,

View file

@ -90,12 +90,12 @@ export class WriteToFileTool extends BaseTool<"write_to_file"> {
newContent = unescapeHtmlEntities(newContent)
}
const fullPath = relPath ? path.resolve(task.cwd, removeClosingTag("path", relPath)) : ""
const fullPath = relPath ? path.resolve(task.cwd, relPath) : ""
const isOutsideWorkspace = isPathOutsideWorkspace(fullPath)
const sharedMessageProps: ClineSayTool = {
tool: fileExists ? "editedExistingFile" : "newFileCreated",
path: getReadablePath(task.cwd, removeClosingTag("path", relPath)),
path: getReadablePath(task.cwd, relPath),
content: newContent,
isOutsideWorkspace,
isProtected: isWriteProtected,

View file

@ -18,8 +18,8 @@ export async function accessMcpResourceTool(
if (block.partial) {
const partialMessage = JSON.stringify({
type: "access_mcp_resource",
serverName: removeClosingTag("server_name", server_name),
uri: removeClosingTag("uri", uri),
serverName: server_name || "",
uri: uri || "",
} satisfies ClineAskUseMcpServer)
await cline.ask("use_mcp_server", partialMessage, block.partial).catch(() => {})