goose icon indicating copy to clipboard operation
goose copied to clipboard

Bug: File rewrites get truncated

Open angiejones opened this issue 10 months ago • 2 comments

Describe the bug When having Goose edit files, it often removes my content and adds some comment to the effect of

// ... [rest of the class implementation stays exactly the same] ...

Of course, this causes the user to lose content and then they have to use more tokens having Goose restore what it accidentally omitted.

I imagine this is due to the snippets provided by the LLM. Can we add/remove from files without total rewrites?

angiejones avatar Feb 14 '25 07:02 angiejones

I am often seeing this error as well. Only for files larger than 1k

CyphrRiot avatar Feb 19 '25 05:02 CyphrRiot

as a workaround, one community member suggested scoping instructions to a specific part of the file (the xyz function). but dont use line numbers, it really struggles with that

angiejones avatar Mar 10 '25 23:03 angiejones

Yea, this does happen and is dependent on the LLM as well. The text_editor_tool in the Developer extension can write (create/overwrite) a file with content or replace a string in a file with new string. Ideally, the latter is what we want to happen for large files so the LLM doesn't get "lazy" and output those comments. We've done some tests and see it mostly work well with claude 3.5 sonnet v2, but it's also not guaranteed (95% of the time it did the right thing). Curious what models are being used when this is seen?

Another potential approach is to put into the goosehints file to always use str_replace instead of write tool for large files. Haven't tried this myself.

Also, if your session is long (using up a good chunk of the context), the model might get more lazy. If possible, start new sessions frequently.

zakiali avatar Mar 24 '25 23:03 zakiali

will close this as this hasn't shown up for a long time across models of all kinds (there were some changes to the write tool - we also have editor fast apply models as an option now)

michaelneale avatar Jul 31 '25 02:07 michaelneale