Instructions didn't stop my agents. Checks on the call did. Four patterns that held up
retained text
I've spent the last few weeks putting a hard check in front of every tool call my agents make, and testing it against two months of my own Claude Code history. The main thing I learned: anything you put in the prompt is a request, and a model under pressure can talk itself past it. A check on the call itself (the tool name and its arguments, before it runs) can't be argued with. Four patterns that held up: 1. **Constrain the argument, not just the tool.** "refund is allowed" is useless. "refund is allowed, amount_usd at most 500, and amount_usd must be present" is a rule. If an argument can be left out to dodge the limit, it isn't a limit. And if the rule lists the arguments a tool may take, anything else should refuse. 2. **Order matters more than I expected.** "refund only after lookup_order was called with the same order_id, earlier in this session" catches the agent that skips the check and goes straight to the action. Keep a digest of the compared values, not the values, so nothing sensitive is stored. 3. **For cost, hold the worst case before the call and settle after.** Counting spend after each call can't stop three parallel calls that each fit the remaining budget alone but not together. Reserving each call's maximum while it's in flight does. And if a call dies midway, charge the worst case: it may already have been billed. 4. **Write the refusal as an instruction.** "Refused: amount over 500. Don't retry it another way; tell the user what you wanted to do" gets a very different next move from "Error: denied". A bare denial sends the model looking for another route. Replaying my own history against a short never-list (recursive deletes, force pushes, `reset --hard`, edits to the agent's own settings) would have stopped 117 `rm -rf` in 8,176 tool calls. Not all were mistakes, but I'd rather it had asked. What's the one action your agent should never take without asking, and how do you enforce it today?
document fetched 2026-10-01 00:20 · canonical https://reddit.com/r/AI_Agents/comments/1wu8qh1/instructions_didnt_stop_my_agents_checks_on_the