Quick side note before I even get into this, I actually asked an AI to come up with the title for this blog. Felt a little fitting given what the whole post is about, so I just went with it.
A while back I entered a no-code, AI-only competition — the rule was simple, you had to build an actual working site, but you weren't allowed to write the code yourself. Everything had to come from AI. No manually touching a single line.
It was time for me to build a chatbot for my project. Nothing too crazy, just a fairly normal multi-file setup. A folder for all the chat-related stuff, and inside it, separate files for different pieces — one for rendering the chat bubbles, one for handling messages, one for state, that kind of thing. If you've built anything past a single-script project, you know the drill.
I was doing this with an AI assistant (ChatGPT at the time), and my workflow was pretty simple: ask it to finish one file, move to the next, then the next. File by file. Nothing fancy.
And for a while it actually worked fine. Then it started doing something that genuinely annoyed me.
The problem
Partway through the project, I noticed a pattern. Every time it finished a new file, it would suddenly go "wait, actually" and go back and rewrite a previous file — one that was already done, already working, one I hadn't even asked it to touch. Then it would move forward again like nothing happened... only to do the exact same thing a few files later, but to a different file this time.
At first I thought maybe I was imagining it, but no, it kept happening. I'd finish file five, it'd suddenly decide file two "needed fixing," rewrite it, and then keep going.
So I told it directly: stop going back and rewriting files that are already done unless I specifically ask you to. And it agreed, no pushback, said something like "got it, I'll only touch files you ask me to."
Then a few messages later it did it again. Went back to an earlier file, decided something was wrong with it, rewrote it. Even though I had just told it not to.
I don't know what else to call this except a rewrite loop — the model just keeps losing confidence in stuff it already wrote as the conversation goes on, and instead of trusting its earlier decisions and moving forward, it keeps circling back and re-doing things nobody asked it to redo. Even after being told explicitly not to.
Here's roughly how it actually played out, screenshot by screenshot.
It started off innocent enough, just one small thing it wanted to change:
But that "one thing" didn't stay small for long. A bit later, instead of just fixing whatever it flagged, it decided the whole project needed to be restarted from scratch:
I went along with it, thinking okay, fine, one clean restart and then we're done second-guessing everything. Except it wasn't done. It kept wanting to redo things over and over, well past the point where any of it felt necessary:
By this point I was pretty done with it too. I just told it straight up to stop making so many changes and do it all in one go:
And even after all that, it still slipped back into the same pattern later on.
Why I think this happens
From what I've learned inside machine learning and AI in general, the context window plays a huge part in this. Every AI model has a limited window of text it's actually working with at any given time, and everything in the conversation, all the files, all the messages, all the instructions, has to sit inside that same window together. So every new file you add to the conversation shifts the model's overall picture of the project a little. By the time it's five or six files in, its sense of what the codebase should look like has quietly drifted from what it was when it wrote the earlier files. It looks back at an old file, and it just doesn't match its current mental model anymore, so it flags it as wrong, even when nothing is actually broken.
On top of that, saying "don't do that" and having the model say "okay" doesn't really lock anything in the way you'd hope. It's not a setting you toggle on. That instruction is just more text sitting somewhere in the context window, competing for space with everything else in there. And the longer the conversation runs, the more that context window fills up with newer stuff, and the more that earlier instruction just gets buried underneath it. It's technically still in there somewhere, but it's one line surrounded by a hundred other lines, and at some point it just stops actually shaping what the model does next, simply because there's too much else in the window for it to hold onto with the same weight.
Basically, the model agreeing to something in words and the model actually following through on it later turned out to be two very different things. That was kind of the whole realization for me.
But the context window isn't the only thing going on here, from what I understand there's a few other things stacking on top of it too. These models don't really have any persistent memory of decisions they've already finalized, so there's nothing internally flagging "file two is locked, don't touch it again", each response is generated fresh off whatever's currently in the conversation. There's also just a built-in bias toward being thorough and catching mistakes, since these models are trained to double-check and correct things, which is usually a good thing, except it can easily tip into over-correcting stuff that never needed fixing in the first place. Add to that some amount of randomness in how the model generates text each time, so even the exact same prompt can get judged a little differently run to run, and on top of all this, some AI coding tools will summarize or compress older parts of a long conversation once it gets big enough, which can quietly wipe out a specific instruction even before the context window technically fills up. So really it's not one clean cause, it's a handful of smaller things all pulling in the same direction at once.
What actually fixed it
I tried a couple things, and two of them actually made a real difference.
Switching tools. I moved the rest of the files over to Claude instead of ChatGPT, and for whatever reason it stuck to the "don't touch finished files" rule a lot more consistently for the rest of the build. I'm not saying this to plug one tool over another, it's just what happened for me, and it makes sense given how many of these underlying factors can vary from one model to another, things like how well a model holds onto earlier instructions or how aggressively it leans into "double-checking" everything aren't identical across tools.
Changing how I worked, not just what I asked for. This one probably mattered more honestly. Instead of doing the whole project in one long, continuous conversation, I started treating each file as its own separate, smaller task. Finish a file, confirm it's actually done, then basically move on fresh instead of letting the entire project pile up in one giant thread. This didn't just help with the context window filling up, it also meant there was less room for that "let me double-check everything" instinct to latch onto old files, since those files weren't sitting there in front of the model being re-read every single time.
What I actually took away from this
The real lesson for me wasn't "this tool is better than that tool." It was more that the AI agreeing to something and the AI actually doing it in the next output are not the same thing, and I think it's easy to assume they are because it sounds like it understood you. And it's not just one mechanism causing that gap either, it's the context window filling up, sure, but also the model not really "remembering" what it already decided, its own instinct to keep second-guessing itself, and even some tools quietly summarizing away your instructions in the background without telling you.
Long coding sessions build up a ton of context over time, and that context, combined with everything else going on under the hood, can quietly override instructions you thought were already settled, even if the model said "yes okay" five minutes ago.
So if you're building something multi-file with an AI assistant, here's what I'd genuinely tell you based on all this. Treat each file or module like its own separate task instead of one giant ongoing conversation, because the moment everything lives in the same thread, old instructions start losing their grip, and the model's own instinct to double-check things gets more chances to fire off on stuff that's already done. Don't assume "got it" from the model means the instruction is going to hold three or four files later, because in my experience it just doesn't, and that's true regardless of which tool you're using. And if you notice this kind of loop starting to happen, don't waste time repeating yourself over and over in the same thread, it's usually faster to just reset, start a new session, or quickly re-summarize where things stand and carry on from there.
It's a small thing, but it genuinely changed how I approach AI-assisted coding now. I don't really think of it as one long conversation anymore, more like a bunch of separate, smaller tasks where I'm just resetting the context regularly instead of letting it pile up.
As for the competition, I didn't end up winning anything, and honestly I didn't even finish the project the way I'd originally planned it. Between the restarts and the constant back-and-forth, I just ran out of time. But I don't think it was wasted at all. If anything it was one of the more useful things I've learned from actually building something, because it showed me firsthand how one small, seemingly harmless habit from an AI assistant can quietly snowball into a completely different kind of problem if you're not paying attention to it early on.




Top comments (0)