Blog | Zencoder – The AI Coding Agent

Prompt Roulette: Why Your AI Breaks After Iteration Three

Written by Shantanu Vishwanadha | Jan 21, 2026 1:16:54 PM

Iteration one feels like magic. You describe a feature, the model delivers something believable, and you think: "We're so back."

Iteration two is usually fine. A tweak here, an edge case there.

Then iteration three hits.

The model changes unrelated files. Tests get weaker. Naming shifts. It "cleans up" working code. The diff becomes impossible to review. You spend more time steering than building—and the productivity gains evaporate.

This pattern has a name: prompt roulette.

It's what happens when shipping depends on how a model feels about your request in that moment, rather than a stable process. And it's why so many teams say, "AI is great... until it isn't."

The Real Problem: Unstable Inputs, Not Bad AI

Most people blame the model when things go sideways. "It got worse." "It forgot my instructions." "Today it's dumb."

Sometimes models do change. But the more common reason is simpler: each iteration changes the inputs in subtle ways.

By iteration three, your AI is operating with:

  • A longer, messier conversation history
  • Conflicting instructions ("keep it simple" + "refactor for clarity" + "don't change anything")
  • Incomplete context (wrong files, missing files)
  • Increasing pressure to satisfy new requests without breaking earlier assumptions

Humans handle messy, evolving context. LLMs recompute the best next answer from whatever you've given them—every single time.

They don't maintain a stable internal "truth." So iteration three isn't a mystery. It's the point where entropy wins.

Research backs this up: Rohan Paul shared a study showing GPT-5 shifted its stated beliefs by 54.7% after just 10 debate rounds. Beliefs and actions drift from context alone, not just from attacks.

Why Iteration Three Is the Tipping Point

Iteration one: "Add input validation to registration."
Simple. Minimal decisions.

Iteration two: "Also handle empty emails and update error messages."
Still manageable.

Iteration three: "Don't change API responses, keep backwards compatibility, don't add dependencies, update tests, and also can you clean up this function?"

Now the model has to juggle behavior constraints, compatibility rules, style preferences, scope limits, test requirements, and refactor temptation.

Unless you've set hard guardrails, it will choose the path that sounds correct rather than the one that is safest.

This is where AI stops acting like a careful teammate and starts acting like a well-meaning intern with too much confidence.

As Itamar Friedman noted, there's a difference between "vibe coding" (prototypes, weekend hacks) and AI-assisted coding you professionally care about. Prompt roulette is what happens when you treat production code like a vibe project.

The Five Failure Modes

  1. Context Creep
    Chat history grows. Old instructions conflict with new ones. The model tries to satisfy everything and the output gets weird—repeating itself, switching approaches midway, contradicting earlier choices.
  2. Scope Drift
    Models start "improving" things you didn't ask for. Reviewers can't tell what changed for the feature vs. aesthetics. Hidden behavior changes sneak in. The PR becomes unmergeable.
  3. Partial Grounding
    The agent reads a few files and starts writing. If it missed the right file, you get confident changes in the wrong place—editing the UI when the bug is in the backend, adding helpers that duplicate existing utilities.
  4. Verification Gaps
    Without automated checks, you're relying on model confidence + reviewer attention. That's not a quality strategy. Iteration three introduces subtle regressions: broken tests, missing edge cases, permission leaks.
  5. Instruction Collisions
    You say "minimal change," "make it robust," "clean it up," "add tests," "don't touch unrelated code," and "quickly please." Those aren't aligned. Models try to satisfy them all and produce a compromise that satisfies none.

What Prompt Roulette Costs

Beyond wasted time:

  • Review time explodes. Big, unclear diffs trigger cautious reviews or endless comment threads.
  • Trust collapses. Once reviewers feel AI PRs are unpredictable, they stop merging them quickly—no matter how good the next one is.
  • Quality becomes inconsistent. Some tasks ship fast. Others create regressions. The variance kills planning.
  • Developer fatigue. Teams spend energy babysitting AI instead of building.

This is why teams plateau: AI is useful for quick wins, but hard to trust for sustained work.

How to Stop Playing Prompt Roulette

The fix isn't "write better prompts." The fix is to move from prompting to process.

Andrej Karpathy shared his rhythm for AI-assisted coding he actually cares about: stuff relevant context, describe single concrete changes, ask for approaches first (not code), review carefully, test, commit. The emphasis is on "keeping a very tight leash on this new over-eager junior intern savant." OpenAI also released a 28-page guide on context engineering—when to trim, summarize, and prevent drift.

Here's the practical implementation:

1. Replace Chat History with Artifacts

Instead of relying on conversation context, use durable documents:

  • Requirements section
  • Technical plan
  • Acceptance criteria
  • Constraint list

When iteration three comes, don't say "as we discussed above." Point to a stable spec: "Follow requirements.md and do not change API output shape."

2. Make Constraints Explicit

Create a standard "must not change" list:

  • No new dependencies
  • Keep response schema
  • No refactor outside touched modules
  • Maintain performance baseline

Put it in a reusable rule file. Include it automatically.

3. Force Scope Control

Require the agent to state:

  • Which files it will change
  • Why those files
  • What it will not touch

This takes 30 seconds and prevents 30 minutes of cleanup.

4. Always Run Verification

Every iteration (not just final), run:

  • Tests
  • Lint/typecheck
  • Build

This turns "I think it works" into "it passed."

5. Use a Second-Pass Reviewer

A reviewer agent catches blind spots:

  • Missing tests
  • Edge cases
  • Security issues
  • Suspicious refactors

Even better if it's a different model family. Different models fail differently.

The Simplest Way to Think About It

If you want AI to be stable across iterations, treat it like a production pipeline:

  1. Define the job
  2. Constrain the job
  3. Run the job
  4. Verify the job
  5. Produce an artifact
  6. Repeat with tight scope

That's what "AI-first engineering" actually looks like. Not a bigger prompt—just a better system.

Closing Thought: The Goal Isn't Smarter AI. It's Less Variance.

The best teams aren't chasing an AI that's magically correct.

They're building a workflow where:

  • The model can't wander
  • The output is testable
  • Iterations don't accumulate chaos
  • Quality stays consistent

Because speed isn't the hard part anymore. Reliability is.

And prompt roulette is what happens when you don't design for it.