Kkarthik.dev
All posts

10 November 2026

My AI agent kept giving refunds it wasn't allowed to give.

Better prompts didn't fix it.

Here's what did ๐Ÿ‘‡

I was building a support agent for refunds, card freezes and account verification.

The policy was clear. The prompt was clear.

But with the right wording, users could still talk it into a refund it should never give.

I tried:
โŒ Stricter system prompts
โŒ More examples
โŒ "NEVER do X" in capital letters

It still slipped.

So I stopped asking the model to follow the policy.

โœ… I moved the policy into code.

The model can suggest a refund. A deterministic guard decides whether it's allowed. If the policy says no, the action never runs, no matter what the model says.

Then I wrote 111 automated tests against it, including prompt-injection attacks.

Result: 0 policy-violating refunds across every run.

The lesson I keep relearning:

โ†’ Prompts guide behaviour.
โ†’ Code enforces it.
โ†’ Tests prove it.

If your agent can move money, delete data or email customers, the rule can't live only in the prompt.

I'm now building more of this in the open: agent-reliability, a tool that breaks AI agents before production by injecting timeouts, bad tool responses and failures halfway through.

I'm also open to AI Engineer / Agentic AI roles in Bengaluru or remote. If your team builds agents that need to work when nobody's watching, let's talk.

What's the worst thing an AI agent has done in your system? ๐Ÿ‘‡

#AIAgents #AgenticAI #LLM #AIEngineering #BuildInPublic

Discuss this on LinkedIn