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.
A test replays one version of a rule over the tool calls your agents made in the last day, week or month. It uses the same engine the SDK runs in your agent. You see how many calls the rule would have fired on, and which ones. Test a rule before you publish it or switch it to Enforce.
You need a saved rule, and a draft is enough. You also need traces from your agent, because the test replays the calls they recorded.
Run a test
- Open Rules and open the rule.
- Scroll down to the Past calls card on the rule's page.
- In the first menu, pick the version to test. The newest is chosen for you, and a version not yet published reads like Version 2, draft.
- In the second menu, pick 24 hours, 7 days or 30 days. The default is 7 days.
- Select Test on past calls in the card. If that version was tested over that window before, the card shows the last result and the button reads Test again.
The replay usually takes a few seconds.
Read the result
The Past calls card leads with the count, such as "Would have fired on 12 past calls". Under it you see how many calls and runs the test replayed.
The table below lists the calls the rule fired on. Each row shows when the call ran, the agent and tool, the decision and the sentence the rule gave. Select a row to open its run.
The By agent table gives the count for each agent. A rule that names one agent counts only that agent's calls.
If nothing would have fired, try 30 days. If the count is still zero, open a run where the call happened. Check that the rule names the same tool and argument the call used.
Change the rule and test again
- Select Edit rule and change the rule.
- Select Save changes. It saves a new draft version.
- Pick that version under Past calls and select Test on past calls.
When every call in the table is one you meant to stop, publish that version.
Next steps
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.
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.
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.
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.
Last updated on