Need more detail? Connect your coding agent to the full docs.

Skip to Content
AMIRILDocs

How rules work

A rule checks each tool call your agent makes and lets it run, flags it or blocks it. Rules run in your agent, and Shadow mode shows what one would do first.

A rule checks the tool calls your agent makes. By default it checks each call before the tool runs, then lets the call run, flags it or blocks it.

A payment cap

Say a payments agent should never pay more than 10000 in one call. This rule says so:

@id("payment-cap")
@sentence("A payment of {amount} is over the 10000 limit")
block (
    agent,
    tool == "issue_payment"
)
when {
    call.args.amount > 10000
};

When the model asks for a payment of 20000, the tool does not run. The model gets this text in place of the tool's result:

The call to issue_payment was not performed. Rule payment-cap blocked it: A payment of 20000 is over the 10000 limit. Do not retry this call with different arguments or achieve the same outcome another way; tell the user it was not performed.

A payment of 500 runs as if the rule were not there.

What a rule can do

A rule's effect is the word before its parentheses. It decides what happens to a call the rule fires on.

EffectWhat happens to a call
blockThe call does not run, and the model is told why
flagThe call runs and is marked for review
bandsThe rule reads a value such as the amount. Its size decides whether the call runs, is flagged or is blocked

A call that no rule fires on runs as normal. A flag rule can also check a call after the tool returns, or once when the run ends. The rule language reference shows how.

Where rules run

The Amiril SDK wraps your agent's tools and checks each call inside your agent's process. Each running process fetches the published rules for the environment of its API key. How rules reach your agent says how and how often.

The rules quickstart runs a rule from a local file and needs no account.

Drafts and modes

Every save makes a new version of the rule, and a new version is a draft. Your agents only ever get the published version, so a draft changes nothing until you publish it.

Publishing sends the version to every environment. Each environment, such as Production, has its own agents and API keys. The rule has its own mode in each one, and a new rule starts in Shadow. The rule's page shows and sets the mode for the environment picked at the top of the app.

ModeWhat the SDK does with the rule
OffNothing. Agents in that environment do not get the rule
ShadowChecks each call and records what the rule would have done. The call runs either way
EnforceActs on the decision. A blocked call does not run

In Shadow, the rule's page counts the calls the rule would have fired on. Watch what it would catch shows where to read the counts.

Test a rule on past calls before you switch it to Enforce. Enforce needs the Team plan.

Where rules come from

You can write a rule yourself in the rule editor, as text or with the builder. Write your first rule walks through it. On the New rule page, Describe the rule takes a request in your own words and writes it in the rule language.

Amiril also drafts rules for you. An issue is a group of your agent's runs that share one problem. When a rule could stop an issue's runs, Amiril drafts one and offers it as a rule suggestion.

Next steps

Last updated on