Skip to content

Repeated issues with the replace (edit) tool #1028

@sijieamoy

Description

@sijieamoy

TLDR

Added by @jackwotherspoon.

Here are main issues being seen with the replace tool:

  • Error: Failed to edit, could not find the string to replace.
  • replace tool misinterprets literal newline characters in the old_string or new_string parameters, leading to syntax errors in the generated code. It seems to treat \n as an actual newline instead of the escaped character
  • 0 occurrences found for old_string.
  • No changes detected

Bug Description

Describe the bug
Here's a very common pattern of GCLI encountered the Error: Failed to edit, could not find the string to replace. error with the replace tool and had to switch to write_file.
'''
✦ I've updated ChatInput.tsx. Now I will fix the errors in VimInput.tsx.
──────────────────────────────────────────────────
│ ✔ Edit ...ges/cli/src/ui/components/VimInput.tsx: interface VimInputProps {... => interface VimInputProps {... │
│ │
│ Error: Failed to edit, could not find the string to replace. │
──────────────────────────────────────────────────

✦ I apologize for the error. It seems I'm still having trouble with the replace tool. I will use write_file to update the VimInput.tsx
file. I will first read the file, then modify the content in memory, and finally write the new content to the file.
╭────────────────────────────────────────────────────────╮
│ ✔ ReadFile ...ges/cli/src/ui/components/VimInput.tsx │
╰────────────────────────────────────────────────────────╯

✦ I have the latest version of the VimInput.tsx file. I will now remove the unused value and onChange props and fix the any type in the
vimDispatch prop.
╭─────────────────────────────────────────────────
│ ✔ WriteFile Writing to ...ges/cli/src/ui/components/VimInput.tsx │
│ │
│ 8 import { VimState } from './vim.js'; │

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent QualitymaintainerFor Roadmap Itemspriority/p1Important and should be addressed in the near term.

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions