ChatGPT keeps removing parts of my code

If I ask ChatGPT to make slight amendments to my Python code, it will remove large and important chunks of code not related to what I’ve asked it to do.

If I ask it to put it back in, it will do, but then it will remove something else.

I have around 170 lines of Python, so not particularly long.

Is this a known bug?

3 Likes

Having same problem with different programming languages.

Same issue - I am creating a graph and it will just not include all the points. I am giving it some old code with about 40 points defined on this graph and it will maybe do about 6. None of the points are redundant to what I want to do and I have made that clear in my prompt.

I’ve been using it for coding for about 6 months, this has always been an issue, particularly if you ask it to give you full code, best to ask for edited segments as you progress through development in my experience

In case it helps anyone, the o3 mini-high model is much better behaved, at least in my compact code (c. 200 lines of python).

Same here for me. I have 150 lines of code with 4o (premium) and canvas. I’ll ask to add a small thing and i explicitly told it NOT to remove anything and i end up with 50 lines less than before. pathetic.

1 Like

I am having the very same issue with my swift code - I cannot rely on chatGPT anymore, very sad, money for nothing and the bugs for free

1 Like

same here with php or C code. i already lost features by chatgpt just deleting entire code paths. like it just removed the login mask from my php code and i only realized a few days after when my cookie expired

@0xbf try using o3-mini-high, I don’t see this issue nearly as often when using that.

@vpatel55
this is what i use :frowning:
you’re right, it is a bit better with that model but all this happened to me with that model.
i am still combing through older git commits to re-add the login form :angry:

Yeah I’m a web developer I have this problem with this **** **** **** and it’s driving me crazy :face_with_symbols_on_mouth: sometimes.

“It looks like some previous content was removed unintentionally. I will restore all missing explanations and details while keeping the new declaration explanations intact. Let me update your canvas with the full content.”

I keep having the same f$&(@( issue with Swift code. I wrote a chatbot in swift playgrounds and then imported it to Xcode. ChatGPT was great at generating code for me to get it working locally and then went off the rails as soon as we started adding new functionality to the bot. After hours dickering around with the new functionality it suddenly decided to wipe out all my chat window functionality!!! It’s still sending messages back and forth to ollama but they are being done in the background now. No more chat history, typing indicator, nothing….oh and it decided to write a line of code the duplicates responses from ollama so now when I look at my console I have the same answer twice to every question I wrote to ollama in testing. FML…a day of work wasted…I have to roll back to the previous working version and start from scratch!

I get the same issue but hopefully this helps.

I am now able to get mr GPT to not delete code and I am 1000 lines deep!
What you need to do is feed it the original code and tell it not to change anything.
Outline what the code is and what it does and make sure mr GPT knows it is important.
Tell mr GPT what you want the new and updated code to do and ask him how he will go about implementing it.
Once he has outlined the steps he has taken.
Ask him specifically to tell you separately what code needs to be changed and the new code to replace it.

Option two:

Do all of the above but instead ask him to “return code in full keeping all necessary features”
It is important also to tell him all of the current code is necessary!

Good luck!

NOTE ** You may find, that sometimes he will respond with an image of the code rather than the code in text form…