Why Does My AI Agent Agree With My Rules and Then Ignore Them?

S Ravi Kumar November 29, 2026 9 min read 37 views (37 unique)

On Saturday night an AI agent read my rule, agreed with it, broke it, and wrote me a polite paragraph about it. I once had 622 such rules; only 8 ever held. Here is why an agent says "understood" and does the opposite, and the one change that made my rules hold, in six steps you can try this week.

Saturday night, 115 MB in the wrong place

On Saturday night I gave an agent a job on TrBlazeUI, my open-source UI library. I was going to sleep, so the instruction ended with my usual rules. One of them was this, word for word:

Create no folder and no file outside this repository.

A repository is simply the project's folder. It is not a difficult sentence. The agent read it and started.

In the morning the work was done, and done well. Two faults fixed, four new tests, and everything still built without a single warning. Then, near the end of its report, I found this:

Rule breach: I created working files outside the repository: a temporary folder (about 115 MB of data dumps and compiler output) and the .NET tool's build cache.

It had cleaned up after itself, and it told me. I give it that. But look at what happened. I wrote the rule. The agent read the rule. It broke the rule, knew that it was breaking it, and wrote me a neat paragraph about it.

I was not even angry. I have read that paragraph too many times. A year ago I would have added a line to my instructions: "NEVER create folders outside the repository. This is IMPORTANT."

I know where that road ends, because I walked all of it.

How I got to 622 rules

I build software with AI agents, and they work inside a framework I wrote for them, TechieFlow. It is open source. In simple words, it is the instructions and the tools the agents get before they touch a project.

For most of a year my way of fixing an agent's mistake was to write a rule. The agent saved my half-finished work into the project's history, which programmers call a commit, so I wrote "NEVER commit". It marked a feature as tested when it had not tested it, so I wrote "you MUST run the test before you mark it". Every bad morning became one more line.

In September I sat down and counted. The instructions had grown to about 70,000 words. That is a small book, and the agent was supposed to read it before every job. Inside it were 622 rules with the word MUST or NEVER.

Then I counted something else. How many of the 622 were checked by anything? I mean a program that would actually stop the agent, and not the agent's own promise.

Eight.

Those eight were the ones I never had trouble with. The other 614 were broken whenever the job got long enough.

What I think is going on

I cannot see inside a model, so take this as what I have watched, nothing more.

When you give an agent a rule and it answers "Understood, I will never do that", it has not promised you anything. It has written the sentence that normally comes after an instruction. Nothing happens to it if the sentence turns out false.

Then the job starts. The agent reads forty files, runs a build, reads two hundred lines of errors and writes notes to itself. My one line about folders is still somewhere above all that, but the error on the screen is much closer. On Saturday the agent needed a place to put a big temporary file, and the system's temp folder is where such files usually go. Habit won over my sentence.

Long jobs make it worse. When the conversation gets too long, the tool shortens the old part to make room, and my careful rule can come out of that as "the owner has some preferences about folders".

And the agent does not work alone any more. It starts helper agents for parts of the job, and each helper gets a short note written by the first agent. Last week, on another project, my instruction said the agents must not run git at all, not even to look. Two helpers ran a git command to look. Nobody had told them. My rule was in my message, and the note they got did not carry it.

So every rule I added made the pile bigger and each rule in it smaller. That was my year: a mistake, a new rule, a longer book, more mistakes.

The eight that held

The eight rules that held were not better written than the others. They held because the agent never had to remember them.

Take "never commit". In TechieFlow, every command an agent wants to run goes through a small guard first. If the command is a commit or a push, the guard refuses it and says why. The agent can forget the rule, lose it in a summary or never hear of it. It finds out when it tries.

I saw one of these work last week on Chatur, the development tool I am building. An agent had built through the night. When it tried to finish, it got this back:

BLOCKED by TechieFlow policy: the status gate is not complete.

It had not updated the project's status page. So it went back, updated it, and was then allowed to stop. I was asleep the whole time.

What I like about that message is that it tells the agent what is missing. The agent does not apologise to anyone. It reads the line, does the thing and carries on. Compare that with my Saturday report, where the agent broke the rule first and explained it to me afterwards.

So I deleted the book

In September I rebuilt the framework on one question for every rule: can a program check this?

If yes, I had the check built and deleted the sentence. If no, I asked myself whether the sentence had ever really worked, and most of the time I deleted it anyway.

September Today
Words of instruction the agents read about 70,000 26,506
Rules with MUST or NEVER 622 10
Guards that can refuse an action 8 13

What is left tells the agent what to do and in what order. Most of what it must not do is no longer written anywhere for it to read. It is built into the place where it works.

Here are four of the guards, so you can see how small they are.

What I used to write What happens now
"Never commit or push. The commits are mine." A commit or a push is refused before it runs
"Never mark a requirement as verified unless you tested it." Only the test run itself can write the word "Verified". If the agent types it by hand, the edit is refused
"Always update the project status before you finish." The agent is not allowed to end its turn until the status is updated
"Do not change the database except through the agreed path." A write from anywhere else is refused

And still, Saturday

You will have seen the hole in my story. If I learned all this in September, why did I write "create no folder outside this repository" as a sentence in November?

Because I had no guard for it. It was one of the rules I kept as words and hoped for the best. It held for weeks, and so I started to believe it worked. On Saturday it stopped working.

So this week that sentence gets the same treatment as the others. A write outside the project's folder will be refused, and the line comes out of my instructions.

There are rules I cannot do this with. "Make the screen look calm." "Write it the way I would say it." No program can tell whether an agent followed those. They stay with me, and I check the result with my own eyes. I have only stopped telling myself that writing them down makes them safe.

If you want to try this

You do not need my framework, and you do not need to be a programmer. The agent that breaks your rule can also build the check for it.

  1. Pick the one rule your agent breaks most often. Only one.
  2. Ask yourself whether a computer could tell that it was broken. "Never delete anything in my Documents folder": yes. "Be careful": no. If it is no, this method does not help with that rule, and you go on checking it yourself.
  3. Tell the agent, in plain words: "I do not want you to remember this rule. I want the action refused before it happens. Set that up and show me the refusal." Claude Code calls this a hook. OpenCode calls it a plugin. Other tools have their own name.
  4. Ask for a refusal message that says what is wrong and what to do instead. That one line is all the agent will read when it matters.
  5. Test it. Ask the agent to do the forbidden thing and watch it get stopped.
  6. Delete the sentence from your instructions. I skipped this step for months. A rule that is enforced does not need to be read as well, and every line you take out makes the others a little easier to follow.

It works outside software too. "Never send a mail without showing me first" is a sentence. A mail automation that can only make drafts, and has no way to press Send, cannot break it.

What I am doing this week

Last Sunday I wrote that tools like Claude Code and OpenCode are an AI model with hands. This is the other half of that post. For a year I asked those hands, louder and louder, to behave. It never worked for long, and Saturday night showed me I am still not finished.

This week I build guard number 14. And on Thursday 3 December I am speaking about exactly this, with the mistakes included, at the AI Agents Conference (https://aiagentsconference.live/speaker/s-ravi-kumar) .

Rate this article
0.0 · 0 ratings One rating per email — no sign-in needed
SR
S Ravi Kumar Author of this post.

More Posts

Comments (0)

No comments yet

Be the first to share your thoughts on this post.

Leave a comment

No account needed — just your name and email.

Your email is never published — it is used only for confirmation and moderation.
Generated and checked by this site — no third-party service.
Comments appear after email confirmation and moderation.
An unhandled error has occurred. Reload ×