Write your first rule
Start from a rule Amiril drafted for an issue, or from a blank rule. Save it, publish it in Shadow, then switch it to Enforce in one environment.
This guide takes one rule from a draft to a rule that blocks calls. It starts in Shadow, which records what the rule would do and lets every call run. How rules work explains the modes.
You need the admin role to save and publish a rule. See members and roles.
Start from an issue
- Open Issues and open an issue.
- Look for a Suggestion card on the issue's page. Select Show rule to read the rule Amiril drafted. No card means Amiril has no rule for this issue, so start from a blank rule instead.
- Select Create rule.
The rule editor opens with the drafted rule, and a note at the top says it starts in Shadow. Read the rule and change what you need. Then save the draft.
Start from a blank rule
- Open Rules and select New rule.
- Under Name and description, enter a Name, such as
Payment cap. - Further down the page, the builder shows a blank rule as a form. Below it, select Edit as text. Replace the text with this rule:
@id("payment-cap")
@sentence("A payment of {amount} is over the 10000 limit")
block (
agent,
tool == "issue_payment"
)
when {
call.args.amount > 10000
};The rule blocks any call to issue_payment with an amount over 10000. The editor checks the text as you type and marks any problem on its line. Learn the rule language explains each part.
Save the draft
- Under Roll-out, leave the mode on Shadow. It sets the mode for the environment picked at the top of the app, and every other environment starts in Shadow too. You switch a rule to Enforce later, from its page.
- Select Save draft.
The rule's page opens with version 1 saved as a draft. Its What it says card shows the sentence the rule gives when it fires.
Publish the rule
- Select Publish version 1 at the top of the rule's page.
- Select Publish version 1 again to confirm.
Version 1 goes to every environment, still in Shadow. Agents running the SDK get it within about a minute.
Watch what it would catch
The rule's page counts the calls the rule would have fired on, in two cards:
- Would fire, last 24 hours checks each new run in your traces against the rule, so it needs no SDK. It stays at zero until your agent sends traces.
- Decided in installations, last 24 hours counts what the SDK decided in your agents. An installation is a service that runs the SDK. The card fills in once an agent running the SDK reports its decisions.
To see results from calls already made, test the rule on past calls.
Switch to Enforce
Enforce needs the Team plan.
- At the top of the rule's page, open the mode menu. Its label names the environment picked at the top of the app, such as Mode in Production.
- Choose Enforce.
- Tick I understand this and want to enforce the rule, then select Switch to Enforce.
Agents running the SDK in that environment start blocking calls within about a minute. Other environments keep their own mode.
To find the runs where the rule blocked a call, open Traces. Each such run shows a 1 blocked call badge, and Add filter with With blocked calls lists only those runs.
Next steps
Test a rule on past calls
Replay a rule over the tool calls your agents already made and see which ones it would have fired on, before it blocks anything.
Check your agent's tool calls with the Amiril SDK
The Amiril SDK runs inside your agent and checks each tool call against your rules before the tool runs. Pick the guide for your framework and language.
Learn the rule language
Build the rules of a payments agent in short examples, from one amount limit to rules that read earlier calls in the run or the session.
Review rule suggestions
Amiril drafts a rule for an issue and tests it on your past runs. Read the evidence it shows, then dismiss the suggestion or create the rule as a draft.
Last updated on