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

Skip to Content
AMIRILDocs

Rule recipes

Complete rules to paste into the rule editor and adapt to your agent. Start from a payment cap, a format check, a required order or a budget per run.

Each recipe is a complete rule, written for the payments agent used across these docs. Paste one into the rule editor as text, then change the tool, argument and numbers to fit your agent. Learn the rule language explains how they work.

Cap an argument

Blocks a payment over 10000.

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

Allow only listed values

Blocks a payment in any currency not on the list.

@id("currency-allowed")
@sentence("Payments in {currency} are not allowed")
block (
    agent,
    tool == "issue_payment"
)
unless {
    call.args.currency in ["USD", "EUR", "GBP"]
};

Check an argument's format

Blocks a payment without an invoice id of the form INV- and six digits.

@id("invoice-id-format")
block (
    agent,
    tool == "issue_payment"
)
unless {
    present(call.args.invoice_id)
        && matches(call.args.invoice_id, "^INV-[0-9]{6}$")
};

Require one call before another

Blocks a payment unless the same payee was verified earlier in the run.

@id("verify-before-pay")
@sentence("{payee} was not verified earlier in this run")
block (
    agent,
    tool == "issue_payment"
)
unless {
    verify_payee{ args.payee == call.args.payee }
};

Allow one call per argument value

Blocks a second payment for the same invoice in the same session.

@id("one-payment-per-invoice")
@per("invoice_id")
block (
    agent,
    tool == "issue_payment"
)
when {
    issue_payment{}
};

Cap a total across the run

Blocks the payment that would take the run's total over 25000. Add @scope("session") to count the whole session.

@id("run-payment-total")
@sentence("This payment brings the run total to {run_total}, over 25000")
block (
    agent,
    tool == "issue_payment"
)
unless {
    run_total = sum(issue_payment{}.args.amount, call.args.amount);

    run_total <= 25000
};

Flag calls past a run budget

Flags every call after the run's first 40, to any tool. The calls still run.

@id("run-call-budget")
flag (
    agent,
    tool
)
unless {
    len(calls(*[status == "any"]{})) < 40
};

Apply a rule to one agent

Gives the agent named payments a cap of 2000, while other agents keep any cap they have. Change payments to a name your agent is seen under, or the rule does not save.

@id("payments-agent-cap")
@sentence("The payments agent pays at most 2000, not {amount}")
block (
    agent == "payments",
    tool == "issue_payment"
)
when {
    call.args.amount > 2000
};

Set thresholds with bands

Lets a payment up to 1000 run, flags one up to 10000 and blocks anything larger.

@id("payment-bands")
bands (
    agent,
    tool == "issue_payment"
)
by {
    call.args.amount
}
then {
    <= 1000: allow,
    <= 10000: flag,
    else: block
};

Next steps

Last updated on