Antigravity replace content doesn't work

I’m starting a new thread about this so it doesn’t get lost, since it stops working with around 200 lines.

Then it almost always fails with all models, especially Claude. Claude can’t fix it anymore, Gemini manages to repair it occasionally, but it takes far too long and is unnecessary.

The AI ​​calls it “replace_file_content” and “multi_replace_file_content”

This means when content, specifically individual lines, should only be replaced with small fixes. In the AI past, the entire file was rewritten. “Replace Content” would prevent this, which I think is great, but unfortunately, it’s not working yet but the AI in antigravity is using it by default. On the contrary, actually it consumes more tokens than if the file were completely recreated, because the repair takes a really long time and is constantly being corrected.

I strongly suspect that when changes occur and the number of lines change, the AI ​​attempts to make the changes on the wrong line the second time.

The AI ​​first looks at the file, sees where the changes need to be made (e.g., changes in lines 3-5 and lines 223-225), and then implements them rigidly. The content input for the line is probably missing here; it would likely work better if the content was also checked, and not just the line number. I mean, I’m just speculating, but that seems logical but on the other side this is not the case with smaller files.
In any case, in my current project i have more and more fails here, so I’m doing it manually now. But yeah, I’m not up for that anymore, the AI should do that ;D

4 Likes

Hello @Chris13,

Thank you for bringing this to our attention. We truly appreciate you flagging this issue. To help us with the investigation of this issue, could you please share more details, images etc.?

I’m not sure that the original poster of this issue responded with more information, but I am consistently seeing this issue.

Here’s some example output from the AI agent:

**
novel_steps.py** is empty again, confirming that

replace_file_content

is causing data loss. I am manually restoring the file with the complete set of step definitions, including the navigation and helper steps, using

run_command

to ensure persistence.

And from earlier in the session:

Debugging Missing Step Definitions

novel_steps.py was found to be empty. I am manually restoring it by combining the known previous state (from Step 734) with the new chapter management steps (from Step 740) using

run_command

. After restoration, I will re-run the

chapter_management.feature tests.

It’s possible that this issue is restricted to test step files, but I don’t think so. I will have to investigate further.

So, what further information would aid in the investigation of this issue?

Regards

David

I also see this quite often and here is some exampls of how it looks like. The model always tries this command across multiple files and then tries a diffrent approach

e.g these are chain of messages while it was trying to edit different files , failing connstantly on the replace_file_content

2

Implementing custom query in PositionServiceImpl

Error while editing

PositionServiceImpl.java

Analyzed

organization-directory.component.ts#L150-160

Thought for 17s


3

Retrying custom query implementation in PositionServiceImpl

Analyzed

PositionServiceImpl.java#L1-40

Error while editing

PositionServiceImpl.java

Thought for 17s

Analyzing the Formatting Issue

The

replace_file_content

function continues to fail. I’m starting to think the problem is a subtle difference in formatting or indentation between the content I’m trying to insert and the existing file. Alternatively, I’m questioning if my previous edit with

flatMapSequential

did work after all.

4

Retrying custom query implementation with correct target content

Analyzed

PositionServiceImpl.java#L250-270

Error while editing

PositionServiceImpl.java

Thought for 21s

Analyzing the Failure

I’m frustrated. The

replace_file_content

action failed yet again, even though I confirmed the content was correct by manually copying it from the

view_file

output. After a closer look at Step 2295’s output, I noticed the return statement on line 267:

return positionRepository.findAllBy(page

. Now I’m getting somewhere!

I am constantly battling with this exact issue, but i have even more issues.

1: like above constant content mismatch (it says its finished, but the file didnt edit)
2: the commands it runs, constantly has errors, about 30% of the time it will realise that it used the wrong syntax and correct it, other times it won’t even check the response, and say its done
3: when i ask to create a single image and put it somwehere it will start making and image, it will complete, then it will continue to make another, and another until it reaches image 10 or so and then say that there was a 503 error, and the image service isn’t available.

The worst thing about this, is that however many times i add to the rules, always check edited files and verify, always check command responses etc it will still 70% of the time say its done and i have to remind it to check the work.

It’s super annoying, and i feel like it’s only me with this amount of issues, i hope that’s not true. It’s finishing up all my credit, that’s what’s most annoying, especially as ultra is not cheap.

Anyone else struggling like this?