Skip to content

Multiple edits should start from the bottom of a file in filesystem server #1591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
phlax opened this issue Apr 26, 2025 · 2 comments
Open
Labels
bug Something isn't working server-filesystem Reference implementation for the Filesystem MCP server - src/filesystem

Comments

@phlax
Copy link

phlax commented Apr 26, 2025

Describe the bug
A clear and concise description of what the bug is.

When editing, the assistant frequently tries to create multiple edits, but if an edit changes the line numbering all the subsequent edits fail, and then it iterates, re-reading, trying again, often deciding that it has to just rewrite the entire file, which can be slow

To Reproduce
Steps to reproduce the behavior:

  1. Request a change with multiple edits to a single file where some will change the line numbering

Expected behavior
A clear and concise description of what you expected to happen.

multiple edits to work

Logs
If applicable, add logs to help explain your problem.

Additional context
Add any other context about the problem here.

I have found that by telling the assistant to explicitly start from the bottom it mostly works

@phlax phlax added the bug Something isn't working label Apr 26, 2025
@phlax phlax changed the title Multiple edits shoudl start from the bottom of a file in filesystem server Multiple edits should start from the bottom of a file in filesystem server Apr 26, 2025
@olaservo olaservo added the server-filesystem Reference implementation for the Filesystem MCP server - src/filesystem label Apr 26, 2025
@sebastien-rosset
Copy link

Are you sure it's the line numbers? I've also had some issues where Claudes goes in a loop trying to edit files. However in most cases it's because the oldText does not match the exact content in the file. The edit_file tool does not take line numbers as input argument.

const EditOperation = z.object({
  oldText: z.string().describe('Text to search for - must match exactly'),
  newText: z.string().describe('Text to replace with')
});

@phlax
Copy link
Author

phlax commented Apr 30, 2025

im not sure of the cause/solution - im certain there is an issue tho - as it almost invariably fails if there is more than one edit (then tries again repeatedly before giving up and just writing the whole file)

i figured it was the line numbers simply because the few times i asked it to start from the bottom it seemed to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server-filesystem Reference implementation for the Filesystem MCP server - src/filesystem
Projects
None yet
Development

No branches or pull requests

3 participants