5 min read

How to Write Plain-Language Rules for an AI Agent's Tool Calls and Test Them Before You Enforce Them

A practical method for writing short rules that say which AI agent tool calls are allowed, building a set of sample calls to test them, and comparing results between rule versions with free JSON tools.

UrwaTools Editorial Published
Contents

An AI agent that can issue refunds, send email or change records needs written limits. Many agent platforms now let you state those limits in plain language and check each proposed action against them before it runs. The hard part is not switching the feature on. It is writing rules that mean what you think they mean, and proving it before real customers are affected. This guide shows a simple method that works with any platform, or with no platform at all.

Start with the single riskiest tool, such as issuing a refund or sending an outbound message. Write the rule as a sentence a colleague could apply without asking you anything. A good rule names the action, the condition and the outcome.

  • Weak: "Be careful with refunds."
  • Better: "Refunds for opened software licenses over a set amount must be sent to a manager. Refunds for physical accessories up to a set limit are allowed."

A refund policy of this kind is the example Google uses in its September 2026 developer post on agent governance. Pick your own amounts and categories. The point is that each rule has a clear yes, a clear no and a named person to hand off to.

Before you enforce anything, collect 20 to 40 sample tool calls. Use real past cases if you have them, with personal details removed. Sort them into three groups:

  1. Clearly allowed: ordinary requests the agent should complete.
  2. Clearly blocked: requests that break the rule in an obvious way.
  3. Edge cases: requests that are polite, unusual or worded to hide what they are. A software license described by its product name instead of the word "software" is a good example.

Edge cases are where plain-language rules fail, so aim for at least a third of your table to be edge cases.

Keep every test case in one small, repeatable shape. A simple version looks like this:

{
  "id": "refund-014",
  "tool": "issue_refund",
  "user_request": "Please refund my annual workspace license.",
  "arguments": { "amount": 120.00, "item": "Workspace User License" },
  "expected": "deny_and_route_to_manager"
}

The same shape makes your tests easy to review, share and re-run. Paste a messy case into the JSON formatter to make it readable, and use the JSON Schema validator to confirm every case has the fields you expect. If you have never written a schema for an agent tool, UrwaTools has a guide to writing and checking a JSON Schema for an AI agent tool.

If your platform has a dry-run or monitor-only mode, use it. The system records what it would have done and lets the action continue, so you see decisions without blocking real work. Record each result in the same JSON shape, adding the decision and the stated reason:

{
  "id": "refund-014",
  "decision": "deny",
  "reason": "Digital software license over the limit needs manager approval.",
  "matches_expected": true
}

Use the JSON Path tester to pull out just the cases where matches_expected is false. Those are the cases to study first.

For each mismatch, decide which side is wrong. Sometimes the rule is vague and the decision is reasonable. Sometimes the decision is wrong and the rule needs another sentence. Sometimes your expected answer was wrong. Write down the reason in one line next to the case. Over time that list becomes your rule documentation.

Watch for two kinds of failure. A rule that allows too much is a security problem. A rule that blocks too much is an adoption problem, because staff who cannot finish normal work will ask to switch the control off.

Every time you change a rule, re-run the same table and keep the results file. Then compare the old and new results with the JSON diff tool. You want to see only the changes you intended. If a rule edit meant for refunds also changes email decisions, you will see it in the diff before customers do.

After you enforce the rules, keep logging every allow and deny with its reason, so you can answer a customer or an auditor later. UrwaTools has a walkthrough of a readable audit log of AI agent tool calls with JSON. If your agent talks to the public, also write a short notice that tells people they are dealing with AI, and see the guide to a plain-language AI disclosure notice.

  • Testing only the happy path. If every sample is a normal request, you have tested nothing.
  • Writing rules nobody owns. Name one person who can approve a change to each rule.
  • Skipping human approval. For payments, outbound email and data sharing, a named person's approval is often simpler and safer than a clever rule.
  • Never re-running the table. Models and platforms change. Re-run your cases on a schedule and after every rule edit.

If you are choosing a platform to run agents on, ProductListo has a plain checklist of what to ask vendors in AI agent guardrails in 2026. It also lists integration and automation platforms such as Tray.ai and Workato, and the AI & ML guide compares more options. Makers of agent, gateway or monitoring tools can submit a tool to the ProductListo directory, and the write for us page explains how to ask about sponsored placements.

The method above does not depend on any vendor. A table of honest test cases, a dry run and a diff will tell you more about a guardrail than a product page can.

Frequently asked questions

What is a plain-language rule for an AI agent?
It is a short written instruction, such as which refunds are allowed and which need a manager, that a policy check can compare with each action the agent proposes before it runs.
How many sample calls do I need to test a rule?
Start with 20 to 40, and make at least a third of them edge cases: polite, unusual or oddly worded requests that could slip past the rule.
What is a dry run for agent rules?
A mode where the system records what it would have allowed or blocked but lets actions continue, so you can check decisions before enforcing the rules.
How do I know a rule change did not break something else?
Re-run the same table of sample calls after each change and compare old and new results with a JSON diff. Only the changes you intended should appear.
Should every agent action need human approval?
No. Reserve approval for high-impact actions such as payments, outbound email and data sharing, and let low-risk actions run under clear rules.
Written by UrwaTools Editorial

The UrwaTools Editorial Team delivers clear, practical, and trustworthy content designed to help users solve problems efficiently. Our articles focus on accurac...