@@ -216,12 +216,10 @@ func deleteContent(edit editContext, filePath, oldString string, replaceAll bool
216216 oldContent, isCrlf := fsext.ToUnixLineEndings(string(content))
217217
218218 var newContent string
219− var deletionCount int
220219
221220 if replaceAll {
222221 newContent = strings.ReplaceAll(oldContent, oldString, "")
223− deletionCount = strings.Count(oldContent, oldString)
224− if deletionCount == 0 {
222+ if newContent == oldContent {
225223 return oldStringNotFoundErr, nil
226224 }
227225 } else {
@@ -236,13 +234,12 @@ func deleteContent(edit editContext, filePath, oldString string, replaceAll bool
236234 }
237235
238236 newContent = oldContent[:index] + oldContent[index+len(oldString):]
239− deletionCount = 1
240237 }
241238
242239 sessionID := GetSessionFromContext(edit.ctx)
243240
244241 if sessionID == "" {
245− return fantasy.ToolResponse{}, fmt.Errorf("session ID is required for creating a new file")
242+ return fantasy.ToolResponse{}, fmt.Errorf("session ID is required for deleting content")
246243 }
247244
248245 _, additions, removals := diff.GenerateDiff(
@@ -299,7 +296,7 @@ func deleteContent(edit editContext, filePath, oldString string, replaceAll bool
299296 }
300297 }
301298 // Store the new version
302− _, err = edit.files.CreateVersion(edit.ctx, sessionID, filePath, "")
299+ _, err = edit.files.CreateVersion(edit.ctx, sessionID, filePath, newContent)
303300 if err != nil {
304301 slog.Error("Error creating file history version", "error", err)
305302 }
@@ -352,14 +349,9 @@ func replaceContent(edit editContext, filePath, oldString, newString string, rep
352349 oldContent, isCrlf := fsext.ToUnixLineEndings(string(content))
353350
354351 var newContent string
355− var replacementCount int
356352
357353 if replaceAll {
358354 newContent = strings.ReplaceAll(oldContent, oldString, newString)
359− replacementCount = strings.Count(oldContent, oldString)
360− if replacementCount == 0 {
361− return oldStringNotFoundErr, nil
362− }
363355 } else {
364356 index := strings.Index(oldContent, oldString)
365357 if index == -1 {
@@ -372,7 +364,6 @@ func replaceContent(edit editContext, filePath, oldString, newString string, rep
372364 }
373365
374366 newContent = oldContent[:index] + newString + oldContent[index+len(oldString):]
375− replacementCount = 1
376367 }
377368
378369 if oldContent == newContent {