Skip to content

Commit 8e384a0

Browse files
committed
Fix #3650: Allow empty content in write_to_file tool
Change validation from !newContent to newContent === undefined to allow empty strings while still rejecting undefined values.
1 parent 9d9880a commit 8e384a0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/core/tools/writeToFileTool.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function writeToFileTool(
2626
let newContent: string | undefined = block.params.content
2727
let predictedLineCount: number | undefined = parseInt(block.params.line_count ?? "0")
2828

29-
if (!relPath || !newContent) {
29+
if (!relPath || newContent === undefined) {
3030
// checking for newContent ensure relPath is complete
3131
// wait so we can determine if it's a new file or editing an existing file
3232
return
@@ -104,15 +104,15 @@ export async function writeToFileTool(
104104
return
105105
}
106106

107-
if (!newContent) {
107+
if (newContent === undefined) {
108108
cline.consecutiveMistakeCount++
109109
cline.recordToolError("write_to_file")
110110
pushToolResult(await cline.sayAndCreateMissingParamError("write_to_file", "content"))
111111
await cline.diffViewProvider.reset()
112112
return
113113
}
114114

115-
if (!predictedLineCount) {
115+
if (predictedLineCount === undefined) {
116116
cline.consecutiveMistakeCount++
117117
cline.recordToolError("write_to_file")
118118

0 commit comments

Comments
 (0)