how to stop your ai agents from breaking production - By Sourav Mishra (@souravvmishra)

my top tips for shipping ai agents that don't go crazy and burn all your money.

BySourav Mishra2 min read

every time an ai agent fails in production, it's the same story: no limits, too many permissions, or no human checking its work.

if you fix these four things, your agents won't blow up your app. here is how i do it.

1. put a limit on loops

if an agent can call tools forever, it will. i've seen agents get stuck and call an api 10,000 times. goodbye budget!

always set a hard stop. if you use the vercel ai sdk, just add stopWhen: stepCountIs(10). if it hits 10 steps, it stops. period.

never launch an agent without a step limit.


2. don't give them god mode

agents shouldn't share a single admin key. if an agent only needs to read a database, give it a read-only token.

if it gets confused or hacked, it can only mess up the little box you put it in.

if this agent goes rogue, what's the worst it can do?

ask yourself that every time. limit the blast radius.


3. put a human in the loop

ai is smart, but it's not "delete production database" smart.

if an action can't be undone (like paying money, deleting users, or publishing posts), make the agent ask a human first.

"agent suggests, human clicks approve." that's the rule.

you can let it search or read stuff on its own, but the big red buttons need a human.


4. check their homework

if you have multiple agents talking to each other, you have to be careful. if agent A goes crazy, it can trick agent B into doing something bad.

never just pass raw text between them. use JSON and validate it. if agent A asks for something weird, block it before agent B even sees it.

honestly, just stick to one agent if you can. it's way easier.


what to remember

  • cap the loop: no infinite runs. ever.
  • least privilege: don't give them all your passwords.
  • human approval: review the scary stuff.
  • validate handoffs: don't let bad agents trick other agents.

get these four things right before you start making it fancy.


written by sourav mishra, keeping bots in check.

Share this post

Cover image for how to stop your ai agents from breaking production

You might also like

See all