Why the AI does the wrong thing
four reasons, and all four are cured by the prompt
What it is
An AI almost never goes wrong "on its own". It does exactly what it heard — it just heard something other than what you meant. There are exactly four reasons, and each has a sign that gives it away.
The article exists so that you don't fix blind. When you get the wrong result, identify the reason first and only then rewrite the prompt: different reasons need different cures, and curing the wrong one adds a second mistake to the first.
What it looks like in code
One task throughout: add a command to the bot that shows the weather. Below are four ways to get the wrong thing.
Reason 1. You didn't say
The most common. You left out a detail and the AI supplied its own.
Add a weather commandIn your head: a bot on aiogram, the key in an environment variable, a
one-line reply. The AI heard none of that and substituted the industry
average: synchronous requests, the key as a string right there in the code,
a five-line reply with emoji.
The sign: the code works, but the solution is not yours. No complaints about the quality; the complaint is about the choices.
The cure: say what was in your head. The four parts of a prompt — article 3.2.
Reason 2. It cannot see
The AI does not know your project unless you show it. In a chat it sees no files at all. An agent in the terminal does see them, but only the ones it has managed to read.
Do it the same way as in the neighbouring handlerThe sign: the AI invents function names, imports modules that don't exist, writes in a style the project doesn't use.
The cure: show it. Paste the file, name the path, tell it to read. If you find yourself explaining the same thing every time, start a project context file (article 3.14).
Reason 3. It remembers something else
The model was trained on whatever code was most plentiful on the internet.
And the most plentiful is code for old versions: aiogram 2 rather than
aiogram 3, React class components rather than hooks, the old Navigator in
Flutter.
Write a handler on aiogramThe sign: the code looks confident and does not run. The errors are
ImportError, AttributeError, "no such parameter". Or the library itself
complains that the approach is deprecated.
The cure: name the version. Not aiogram but aiogram 3. Not React
but React 18, function components, hooks.
Reason 4. It heard you literally
The AI did exactly what was asked. The trouble is that what was asked was the wrong thing.
Get rid of this errorThe error will disappear. Most likely it will be wrapped in a try/except
and suppressed — formally, the request was fulfilled. The difference between
"get rid of the error" and "fix the cause" is obvious to you and not to the
AI.
The sign: the task is closed, the symptom is gone, the problem remains. Or it left together with behaviour you needed.
The cure: state the goal, not the action. Not "get rid of the error" but
"make the server error be handled in fetch_weather".
What to tell the AI
A summary table — the reason can be identified from it in seconds.
| What you see | Reason | What to do |
|---|---|---|
| Working code, but not your solution | you didn't say | name the specifics |
| Invented names, foreign style | it cannot see | show the files |
Won't run, ImportError | remembers something else | name the version |
| Symptom gone, problem stayed | heard you literally | name the goal, not the action |
When the reason isn't clear, ask the AI itself — it answers this honestly:
Before you change anything: which assumptions did you rely on
when writing this code? Which of them did I never tell you?What to look for
Don't fix reason 1 with the cure for reason 3. The typical scene: you got the wrong result, you start adding more and more detail to the prompt, and the code still doesn't run — because the problem was the version, not the detail.
One task, one reason at a time. When you rewrite the prompt, change one thing. Otherwise you won't know what helped, and next time you'll be guessing again.
"It's stupid" is not a reason. That feeling comes from reason 4, when the AI did literally what was asked. Check what you asked for, not what you meant.
Cheat sheet
Four reasons: you didn't say · it can't see · it remembers something else · it heard you literally.
Identify the reason first, rewrite the prompt second.
Always name the version: no amount of detail cures that one.
State the goal, not the action.
Not sure why — ask which assumptions it relied on.