We run our own business development on a team of AI agents: a chief of staff and seventeen specialists that research companies, check facts, write emails and keep records on a schedule, mostly while nobody is watching. They are good at it. They are also language models, which means that on any given day one of them will write something it shouldn't.
So the agents don't send anything. They write. A plain Python program decides whether each email goes, and that program has no opinion about tone, persuasion or context. It has a list of checks, in order, and it stops at the first one that fails.
This post is about that list, and about why I now think most of an agent's safety belongs in boring code rather than in the prompt.
Prompts state intent. Code states what can happen.
Our prompts are long and careful. They explain who we email, why, and what we never say. But a prompt is a request. A model that follows it 99 times out of 100 will still send the hundredth email, and at our volume the hundredth arrives every week.
Rules also change. On 2 December we decided that we never give a price before the client has agreed a written technical scope. That day the prompts changed, and so did a regular expression. The prompt makes the agents write it correctly most of the time. The regex makes sure the rest never leave.
The shape
The agents produce a plan: a JSON file of items, each with a recipient, a subject, a body, a status, and the evidence for why this address is the right one. The sender walks the plan item by item:
for item in ready_items(plan): why = ( qa_problem(item) # a separate review step must have passed it or not_before(item) # scheduled for later or cap_problem(item, today) # daily cap, lower cap for first emails or brake_problem(item) # 7-day bounce brake, per lane or history_problem(item) # bounced, replied, already sent, emailed since or recipient_problem(item) # address must be one the evidence supports or lint(item.subject, item.body) # content guards: price, tone, template rules or crm_problem(item) # stage, do-not-contact, who owns the lead ) if why: skip(item, why) continue send(item) That is simplified, but the order is real, and so is the rule that the first failure wins and is written down.
The checks that earn their keep
The recipient must be backed by evidence. A first email may only go to an address the company publishes itself, on its own website or its own business page, and the plan has to show where it was found. A follow-up must go to the same address the first email went to. An agent that "finds" a plausible address by pattern-guessing gets a skip, not a send.
History beats the plan. The plan is built hours before the send. In between, someone may have replied, an address may have bounced, or another process may have emailed the same person. The sender reads the ledger again at send time and refuses anything the world has overtaken.
The bounce brake. For each lane of email, the sender reads the bounce rate of the last seven days' first emails. Over 5%, the day's cap for first emails is halved. Over 8%, first emails stop until a person clears the brake with a note saying what they fixed, or a week passes. There is also a same-day stop at 5%. Each lane is judged on its own bounces, so a bad day in one doesn't stop the others.
Content guards that speak to the model. The price guard is a regular expression that knows prices in English and Arabic: currency codes before or after a number, Arabic currency words (which need no word boundary, because Arabic attaches them), Arabic-Indic digits like ٢٥٠٠, and phrases such as "fixed price" or "rate card". When it fires, the reason it returns is written for the agent, not for me:
names a price or pricing terms ('fixed price'): scope before price. Say a written technical scope comes first and the founder sends pricing after they've agreed it The reason is written into the plan next to the item, so whoever rebuilds it, agent or person, knows exactly what to change. A refusal that explains itself turns a guard into feedback.
We have a tone guard too. It catches gatekeeping lines like "before I even consider a call", which one of our agents produced in a reply that was technically polite and still read as rude. The guard asks for the opposite: welcome the call, and ask the questions as help.
Skips that wait and skips that stick
Not every skip means the same thing. "Cap reached" or "not before 18:40" leaves the item ready for the next run. "Address bounced", "lead replied" or a content failure marks it skipped for good, with the reason in the file. That split matters: an agent should retry the first kind and rethink the second.
What I'd tell anyone building agents for a business
- Put the irreversible step behind code the model can't edit. Sending, paying, deleting and publishing should each sit behind a deterministic gate with its own checks.
- Re-read the world at the moment of action. Plans go stale. The check that matters is the one done one second before the send.
- Make every refusal a sentence the model can act on. "Blocked" teaches nothing; "say a scope comes first" does.
- Keep one sender. When two processes can send, your caps and histories are fiction. We allow exactly one sender at a time and make everything else hand its email to it.
- Log every decision. Because each skip and send is recorded with its reason, we can replay any day afterwards and see what each agent did and which rule stopped it.
None of this is clever. That's the point. The agents can be as creative as they like, because the part of the system that touches the outside world is the least creative code we have.
I'm Abdelrahman, founder of ARO Solutions in Amman, Jordan. We build AI agents like these for companies, in English and Arabic: https://www.aro.solutions/solutions/ai-agents?utm_source=devto&utm_medium=article&utm_campaign=agent-rules

