AI Joe
← Blog· Engineering Reality

Same Prompt, Different Code: The Model Isn't Guessing, You Are

July 17, 2026

Why it matters: Developers who blame AI for inconsistent output are missing the actual fix, and it costs them hours of re-running prompts hoping for a lucky draw.

The Details:

  • Language models generate text by sampling from a probability distribution over the next possible word. A single different token pick early in the response steers every token after it, so two runs of the same prompt can diverge into completely different but equally valid solutions within a few words. Temperature settings control how wide that sampling net is cast.

  • Most real coding tasks have many defensible answers, not one hidden correct answer waiting to be uncovered. A request for a rate limiter can honestly become a class, a set of closures, or a decorator, and all three can pass the same tests. Re-running the prompt until you get the version you had in mind is not debugging, it is gambling on which valid answer lands next.

  • The actual fix sits upstream of generation: state the constraints you were carrying silently in your head. Say you need a class, say it must be injectable for tests, say the state has to be observable for debugging. Adding those details narrows the model's sampling space so sharply that the variation stops mattering because the acceptable output range now matches what you actually need.

  • Writing those constraints down does something extra: it forces you to test which of your engineering habits are real judgment and which are just leftover convention. A prompt specific enough to produce consistent output starts to function like a design document, and teams that version and review it the same way they review code end up with a written record of standards that used to live only in one senior engineer's head.

Bottom Line: The model handles generation, but consistency is your job, and it only comes from constraints you actually write down.

Enjoy this article?

Listen to the Claude Code Conversations radio show or join the community.