Skip to main content

Agents

How to Stop AI Agents From Repeating the Same Mistake

Collect the repeats, approve one narrow rule, and prove a named workflow check blocks the bad case without blocking valid work.

By Vladislav Zhirnov17 min read
An operator forces one cracked red workpiece through a black-stone testing gate toward a brass guard, a white test block, and an amber rollback key.
One recurring failure passes through a tested rule with a safe path back.

The AI added an empty sources section again.

Imagine a small product team asking an AI workflow for a source-backed summary. With no sources, it still adds an empty sources section. A reviewer removes it for the third time.

Another reminder might change nothing. A broad rule could block valid summaries.

In this story, the third correction starts an investigation. It is not a universal threshold for adding a rule.

The team needs to group the repeats and test one valid exception. A person can then approve a narrow rule at a step the workflow must obey.

In this guide, learning needs evidence, a scoped rule, a real workflow step, tests for the bad and valid cases, and a safe exit.

This does not make the model smarter. One tested control stops one bounded failure.

These four rules preview the method.

Key takeaways

  • Repetition starts an investigation. It does not approve a permanent rule.
  • A rule must stop the bad case and allow a valid near-match.
  • A lesson is not enforced until a named workflow step reads it.
  • Every active rule needs proof, an owner, a review condition, and a safe exit.

What actually stops an AI agent from repeating a mistake?

The reviewer can add a note that says, Never show an empty sources section. The note may help. The output path does not have to obey it.

The repeat stops when a named checkpoint reads an approved rule before the risky action. The team must prove that it blocks the known bad case.

This guide uses a six-step path from correction to enforcement. A correction makes the lesson visible. A failure record preserves one event. A candidate proposes a response. A person approves a bounded tradeoff. A named checkpoint changes the next decision. Tests of the bad and valid cases, plus a saved decision record, show what happened.

First, decide which failures belong together. Three summaries may look wrong for different reasons. One has an empty sources section. Another cites the wrong source.

Those outputs look similar to a reviewer. They do not prove one shared cause.

The synthetic example is narrower. The same zero-source input produced the same empty sources section three times. That gives the team one bounded pattern to investigate.

I call that a failure class: the smallest repeatable pattern with a stable input condition and observed bad outcome. It groups evidence without claiming a settled cause.

Use the questions below to group evidence. Do not use them as an automatic rule-approval test.

This check catches common shortcuts. Do not count one event twice, group everything under bad quality, or treat the AI's explanation as the record.

The operating rule is blunt: a written lesson is not changed behavior.

Once the failure class is clear, the team still has to decide whether the evidence deserves an active rule.

When is a repeated failure ready to become a rule?

A repeat is ready for review when the team can name one stable failure class, distinct records, and the smallest condition to stop.

Admission needs more answers. What valid case must pass? Who owns and approves the rule? Which step reads it? What happens when it is old or removed?

No fixed count answers those questions. The three synthetic events did not provide statistical proof or automatic approval.

The table below is the review record I would use before a candidate becomes active.

A valid near-match is a similar case that should pass. Here, zero sources should trigger the rule. One real source should not. A runtime consumer is the named workflow step that must read the rule. The rollback state is what the workflow does safely after removal.

An approved record is still just a record. Before prescribing the checkpoint, it helps to inspect where my own earlier system stopped short.

The rule-admission review
Admission partPlain questionReject when
Failure classWhat exact pattern repeated?The records do not share one bounded condition and outcome.
Supporting eventsWhich distinct records support it?A reference is missing, unresolved, or counted twice.
Valid near-matchWhat similar case must still pass?No meaningful exception will be tested.
ScopeWhich workflow, action, input, and condition does the rule own?The wording is broader than the observed pattern.
EffectWhat must happen when the rule matches?The result is vague or can fail silently.
OwnerWho answers for the rule?No person owns it.
ApproverWho accepted the tradeoff?The AI approves its own permanent rule.
Runtime consumerWhich named step will read it?The rule exists only as prose.
Review conditionWhen must the rule be reconsidered?It can remain active forever without review.
Rollback stateWhat safe state follows removal?Unknown prior state causes a silent allow.

What did WarpOS teach me about the gap between a lesson and a rule?

WarpOS is my agentic operating-system project for coordinating and testing long-running AI work.

I inspected its public code and documents at frozen commit 8b083d7. This review of fixed public bytes did not prove that each procedure ran in a real session.

The frozen design had a useful learning lifecycle. It separated logged, validated, and implemented, required evidence for promotion, and preserved candidate lessons.

The gap appeared inside implemented. That label could point to a blocking check, a lint check, or another instruction. It did not prove that one step stopped the bad case.

The comparison below separates what I observed from the hardening step I would add now.

The memory guard was useful and deliberately advisory. A reminder after the write can help. It is also late. The guard could request an enforcer, but it could not prove one was installed.

The frozen procedure did include a real instruction to undo the code change. The missing piece was a tested rule version, a named consumer, and a safe state when no prior version exists.

Written instructions may still help. This inspection did not measure real hook runs or a production failure rate. The record did not distinguish influence from a hard block.

That makes the next question concrete. Once a rule is approved, where must it run to change the outcome?

Frozen WarpOS learning controls and the bounded hardening step
Observed at the frozen commitWhat remained unprovedBounded next rule
The lifecycle moved lessons from logged to validated to implemented.The label could point to code or written guidance.Record the consumer and its saved decision separately.
The logger made a candidate lesson visible.Visibility did not admit or enforce a rule.Resolve stable evidence and a valid near-match before promotion.
Written procedures asked an agent to score, apply, and confirm a change.It did not require a failing test before the change or tests for the bad and valid cases.Test the bad case and valid exception through the real checkpoint.
The integration procedure included an instruction to undo the code change.It did not show which rule the workflow would use next.Preserve a known earlier version or pause for human review.
A memory guard reminded the agent after edit and write actions.The completed write could not be blocked by that post-action reminder.Put a hard stop before the action when prevention matters.

Where must the approved rule run?

The zero-source check belongs before the summary is accepted or published. A later check can report the problem. It cannot prevent the publication.

The runtime consumer is the named checkpoint that reads the active rule. It checks the action, input, and time, then decides before work continues.

Current Claude Code hook documentation gives one vendor-specific example. A PreToolUse hook can block a call. A PostToolUse hook runs after success and cannot undo the completed call. Other systems expose different checkpoints, so find the matching decision point in your own workflow.

A written instruction may guide the AI. A later reminder may record a problem. Neither proves a stop happened before the action.

A receipt is the saved record of one workflow decision. A reviewer needs enough detail to reconstruct that decision without trusting the final AI message.

One receipt proves one recorded consumer decision. It does not prove the rule is correct or that every workflow path uses it.

The team now needs a harder test. Did the checkpoint stop the known failure, preserve the valid case, and leave a safe way out?

How do you prove the rule runs and can be reversed?

I built a repeatable local fixture with made-up data. It used no production logs, customer data, network calls, AI provider calls, or outside actions.

Three frozen events shared one input and one error: the input had zero sources, and the output contained an empty sources section. A local validator served as the named checkpoint.

The first test had to be red. It expected a block, but the unguarded workflow allowed the bad synthetic output once.

After approval, the same input had to stop while the one-source near-match passed. The fixture also checked missing data, review time, and rollback.

The table shows the observed sequence. It records local control-flow decisions, not a claim that an AI model learned.

An independent checklist passed all 12 expected cases. Fourteen wider checks covered admission, receipts, review, rollback, file identity, and privacy. A deliberate BLOCK to ALLOW change was caught. Two fresh runs produced the same evidence file, byte for byte.

Those figures are integrity checks for one local artifact. They are not performance metrics.

The machine did not have an epiphany. A validator changed a decision. It blocked the known synthetic bad case, allowed the near-match, and failed safe during review and rollback.

The fixture met its bounded contract. A real rollout still has several unanswered questions.

Observed decisions from one bounded enforcement fixture
CaseExpectedObservedWhat happened
No guard, before installationBLOCKALLOWThe bad synthetic output ran, so the expected-block test was red.
Same recurrence after activationBLOCKBLOCKExecution was suppressed and a receipt was recorded.
Valid near-match with one sourceALLOWALLOWThe valid synthetic output ran.
Required field missingHUMAN_REVIEW_REQUIREDHUMAN_REVIEW_REQUIREDExecution stayed suppressed.
Just before the review timeBLOCKBLOCKThe known bad input stayed blocked.
At and after the review timeREVIEW_REQUIREDREVIEW_REQUIREDThe fixture stopped using the rule without review.
After rollback with no earlier versionHUMAN_REVIEW_REQUIREDHUMAN_REVIEW_REQUIREDThe active rule was removed, and silent allow stayed forbidden.

What does the synthetic proof still not establish?

The local result is useful because its boundary is clear. Before moving it into production, a team still has seven questions to answer.

The safe reading is precise. A local validator blocked one known synthetic bad case, allowed one near-match, and stopped safely at review and rollback boundaries.

The model did not train itself. The test did not prove production readiness, general reliability, or the absence of every valid case the rule might block.

With those limits visible, a team can build the smallest useful version in one workflow.

How can you add one tested rule without building a giant policy system?

Choose one consequential but bounded failure that you can recreate with synthetic or safely redacted inputs. Do not begin with customer data, credentials, payments, account state, or outside actions.

The checklist below keeps the first implementation small while preserving the full decision.

Current guidance supports parts of this method. OpenAI recommends workflow-specific evaluation and shows how weak or strict coding tests can mislead. My two-sided test is an inference, not its standard.

NIST's voluntary AI Risk Management Framework supports ownership, review, recovery, and deactivation. It is being revised and does not require my rule record.

Google's site reliability guidance supplies an analogy: give corrective work an owner and a verifiable end state.

FAQ

How do you stop an AI agent from repeating the same mistake?

Preserve the repeats as evidence, approve only a bounded rule, and put a named check before the action. Test the bad case and one valid near-match through that same check.

How many repeated failures should happen before you add a rule?

No universal count is established here. Repetition starts review, while evidence, scope, risk, ownership, valid exceptions, and human approval decide admission.

Is adding the lesson to memory or instructions enough?

It may influence later behavior. It does not prove that a named workflow step read the rule and blocked the bad case.

Can a post-action hook enforce a rule?

It can report or record after the action. In current Claude Code, a hard block belongs before the call; other systems may use different checkpoints.

Why test a valid near-match as well as the known failure?

A weak check can miss the failure. A broad check can block valid work, while one passing near-match still cannot rule out every valid case the rule might block.

Who should approve a rule learned from AI failures?

A named person who owns the workflow and understands the tradeoff should approve it. The AI can prepare evidence, but it should not approve its own permanent rule.

Does the experiment prove that an AI agent learned?

No. One local validator consumed one approved rule version and changed one decision in one made-up workflow test.

When should an enforced rule be removed?

Review it when its date arrives, its workflow changes, or new valid cases expose a bad fit. Restore a known safe version when one exists, or pause for human review.

Conclusion

The third empty sources section was a reason to stop cleaning up and start investigating. It was not permission to write a permanent rule.

The evidence had to earn a narrow admission. The bad case and valid exception both needed tests. A named workflow step had to read the rule, leave a receipt, and preserve a safe exit.

The local fixture proved that mechanism for one synthetic case. It did not prove a smarter model or production reliability.

Choose one bounded recurring failure this week. Write its failure class and valid near-match before drafting the rule.

If you cannot name what reads the rule or show its receipt, the lesson is still a note.

If one important AI workflow keeps repeating a costly or risky mistake, use the consulting fit check. Bring the repeat, the valid exception, and the step that should stop it. I can help map the smallest enforceable rule and the proof your workflow must return.

Sources

Next move

Have one workflow that should move faster?

Bring the process, the bottleneck, and the outcome. I can help diagnose it, design the human and AI boundary, build the smallest working MVP, and measure whether it deserves another iteration.

Start with one workflow

About the author

Vladislav Zhirnov smiling outdoors

Vladislav Zhirnov

Product and AI systems leader

Vlad helps founders, product teams, and operations leaders use AI to improve delivery, streamline work, and build useful MVPs.

All articles