ai newsFr., 23. Okt.
EilmeldungOpenAI skaliert Online-Speicher fuer ueber eine Milliarde ChatGPT-Nutzer

When AI keeps fixing the wrong bug

Anyone who has debugged with an AI model knows this loop. You paste the error, ask for a fix, and get a confident patch. It looks right. The error moves somewhere else. You paste the new error, get another patch, and a few rounds later the code is messier and nobody, human or model, can say what th

dev.toFreitag 17:50 · 23.10.3 Min. Lesezeit
Bild: dev.to

Anyone who has debugged with an AI model knows this loop. You paste the error, ask for a fix, and get a confident patch. It looks right. The error moves somewhere else. You paste the new error, get another patch, and a few rounds later the code is messier and nobody, human or model, can say what the bug actually was.

The model usually isn't the problem. "Fix this" quietly asks for four different things at once: a way to reproduce the bug, a place where it lives, a reason it happens, and a check that the fix didn't break something nearby. Asked all at once, the model jumps to the last step and guesses at the first three.

What breaks the loop is asking for one stage at a time, with a prompt that only wants that stage's answer. Here are four.

Below is a bug report and whatever logs or error output I have. Write the shortest set of steps that should reproduce it, starting from a clean state. For each step, say what I should see if the bug is present and what I'd see if it isn't. If the report is missing something needed to reproduce it (version, environment, input data), list those gaps first as questions, before any steps. Enter fullscreen mode Exit fullscreen mode The aim here is a recipe, not a theory. Asking for the gaps first stops the model guessing an environment and sending you down the wrong path.

The bug reproduces with the steps below. Here is the code I think is involved. Suggest a sequence of checks that halves the search space each time: what to comment out, log, or hard-code, and in what order. For each check, say what result would rule a part in or out. Don't propose a fix yet. Enter fullscreen mode Exit fullscreen mode "Don't propose a fix yet" carries a lot of weight. Without it, most replies skip straight to a patch for whatever looks suspicious.

Here is the code where the bug lives, and what I found while isolating it. Explain the cause in plain language: what the code assumes, where that assumption breaks, and why it only shows up under these conditions. Then give one sentence I could use in a code comment. Enter fullscreen mode Exit fullscreen mode This is the step people skip, and it's the one that stops the same bug coming back in a different file. If the explanation doesn't hold up against what you saw while isolating, you're not done.

Here is the fix, and the explanation of what caused the bug. The bug came from a wrong assumption in the code. Point to other places in this code that could rely on the same assumption, and for each one, say what input or condition would break it. Don't rewrite anything. Just tell me where to look. Enter fullscreen mode Exit fullscreen mode A fix closes one instance of the problem. This step asks what else the same wrong assumption could break, which is often where the next bug is waiting.

Writing four careful prompts once is easy enough. The trouble is that by the next bug they're buried in an old chat, and "fix this" is right there in a fresh one. That's how the loop starts again.

Saving them is what stops it. We make PromptAlo, a Chrome extension that keeps your prompts in a library with AI tags and sends any of them to ChatGPT, Claude or Gemini in one click. Save the four stages once and the next bug starts at Reproduce instead of at "fix this": https://chromewebstore.google.com/detail/promptalo/jlfoipkmagdoafhlkhfkakdankpjhgni?utm_source=devto&utm_medium=brand_post&utm_campaign=w6-fri-devto-store

Which stage of a bug do you find hardest to get a straight answer on from AI?

This post was written with AI assistance and edited by the PromptAlo team.

Quelle: dev.to (dev.to). Original öffnen