From 66f9bdab32b21110c0dd9ce0aaa8d928aea8eba2 Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Mon, 12 Jan 2026 20:39:57 -0600 Subject: [PATCH] core: tweak edit and write tool outputs to prevent agent from thinking edit didn't apply --- packages/opencode/src/tool/edit.ts | 4 ++-- packages/opencode/src/tool/write.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/opencode/src/tool/edit.ts b/packages/opencode/src/tool/edit.ts index b68078f14..7ace4e4a2 100644 --- a/packages/opencode/src/tool/edit.ts +++ b/packages/opencode/src/tool/edit.ts @@ -119,7 +119,7 @@ export const EditTool = Tool.define("edit", { }, }) - let output = "" + let output = "Edit applied successfully." await LSP.touchFile(filePath, true) const diagnostics = await LSP.diagnostics() const normalizedFilePath = Filesystem.normalizePath(filePath) @@ -129,7 +129,7 @@ export const EditTool = Tool.define("edit", { const limited = errors.slice(0, MAX_DIAGNOSTICS_PER_FILE) const suffix = errors.length > MAX_DIAGNOSTICS_PER_FILE ? `\n... and ${errors.length - MAX_DIAGNOSTICS_PER_FILE} more` : "" - output += `\nThis file has errors, please fix\n\n${limited.map(LSP.Diagnostic.pretty).join("\n")}${suffix}\n\n` + output += `\n\nLSP errors detected in this file:\n\n${limited.map(LSP.Diagnostic.pretty).join("\n")}${suffix}\n` } return { diff --git a/packages/opencode/src/tool/write.ts b/packages/opencode/src/tool/write.ts index 222bac3f8..d621a6e26 100644 --- a/packages/opencode/src/tool/write.ts +++ b/packages/opencode/src/tool/write.ts @@ -47,7 +47,7 @@ export const WriteTool = Tool.define("write", { }) FileTime.read(ctx.sessionID, filepath) - let output = "" + let output = "Wrote file successfully." await LSP.touchFile(filepath, true) const diagnostics = await LSP.diagnostics() const normalizedFilepath = Filesystem.normalizePath(filepath) @@ -59,12 +59,12 @@ export const WriteTool = Tool.define("write", { const suffix = errors.length > MAX_DIAGNOSTICS_PER_FILE ? `\n... and ${errors.length - MAX_DIAGNOSTICS_PER_FILE} more` : "" if (file === normalizedFilepath) { - output += `\nThis file has errors, please fix\n\n${limited.map(LSP.Diagnostic.pretty).join("\n")}${suffix}\n\n` + output += `\n\nLSP errors detected in this file:\n\n${limited.map(LSP.Diagnostic.pretty).join("\n")}${suffix}\n` continue } if (projectDiagnosticsCount >= MAX_PROJECT_DIAGNOSTICS_FILES) continue projectDiagnosticsCount++ - output += `\n\n${file}\n${limited.map(LSP.Diagnostic.pretty).join("\n")}${suffix}\n\n` + output += `\n\nLSP errors detected in other files:\n\n${limited.map(LSP.Diagnostic.pretty).join("\n")}${suffix}\n` } return {