Skip to main content
Kliff

Where models go wrong

The common ways a model gives a wrong answer with confidence, and the habits that catch them.

Video coming soon

Models are useful because they are fluent, and risky for the same reason. A wrong answer usually reads just as smoothly as a right one. This lesson covers the mistakes you will see most often when you work with a coding agent, and the habits that catch them before they reach your main branch.

Hallucination: plausible, but not real

A hallucination is an answer the model made up that looks like a fact. In code it often shows up as:

  • A function, method, or option that does not exist, named the way it would be if it did.
  • A command line flag borrowed from a similar tool.
  • A file path that fits your project's layout but is not there.
  • A confident explanation of what some code does, written without reading it.

Here is a typical case. You ask for a helper that retries a request, and the model writes:

Source codejs
const response = await fetch(url, { retries: 3 });

It looks reasonable. But the standard fetch has no retries option. In plain JavaScript the unknown option is simply ignored, so nothing fails until the network does. In TypeScript, the type checker would flag it, which is a good example of why running checks matters.

This is a direct result of how models work. The model writes what fits the pattern. When the true answer is rare or missing from its training, the most fitting continuation can be something that should exist but does not.

Limits you can plan around

Some limits come up again and again:

  • Stale knowledge. A model knows a library as it was when its training data was collected. A newer version may have renamed or removed what it suggests.
  • No view of your code by default. Unless the model has read a file, anything it says about that file is a guess.
  • Exact work. Counting, long arithmetic, and keeping track of many precise details at once are weak spots. A model can describe an algorithm well and still slip in a step.
  • Agreeing too easily. If you suggest a cause, a model may run with it even when the evidence points elsewhere. Ask it to check your idea, not to confirm it.
  • Drifting on long tasks. Over a long session a model can lose track of an earlier constraint, or quietly change its approach.

None of these mean the model is not useful. They tell you where to look harder.

Ground the model in real sources

The best defense against made-up answers is to give the model the real thing to work from, and to ask it to show its work.

  • Ask it to read the code before it explains or changes it, and to name the files and lines it relied on.
  • Point it at the version of a library you actually use, such as your lockfile or the library's own docs.
  • When it cites an API, ask where that API is defined. If it cannot point to a definition, treat the API as suspect.

An agent that can read files and run commands is much less likely to invent things about your code, because it can check instead of guess. That is one of the main reasons agents are more reliable than a plain chat for real work.

Verify by running, not by reading

Reading a diff and finding it plausible is not verification. Most model mistakes look fine on the page.

Prefer checks that run:

A prompt that asks for prooftext
Add the retry helper, then write a test that makes the first two
requests fail and the third succeed. Run the test and show me the output.

Tests, type checks, linters, and actually starting the app turn a model's claim into evidence. When something cannot be checked automatically, ask for the reproduction steps and try them yourself.

Key points

  • Models can produce confident, plausible answers that are wrong, including APIs and options that do not exist.
  • Knowledge goes stale, private code is unknown until read, and exact bookkeeping is a weak spot.
  • Ask the model to read first and cite what it relied on, so answers rest on real sources.
  • Treat running checks as the proof. A plausible diff is not a verified one.