AI agent guardrails that stop bad tool calls before they run
Amiril's AI agent guardrails check each tool call in your agent's process and block any that break a rule. A new rule only records until you turn on Enforce.
Amiril's AI agent guardrails check each tool call in your agent's process and block any that break a rule. A new rule only records until you turn on Enforce.
A customer tells a support agent they were charged ten times for an order that cost 90. The model believes them and calls issue_refund with an amount of 900. Most AI agent guardrails look for harmful or private text, which that conversation doesn't contain. They read the user's message on the way in and the model's reply on the way out. The user guide for Amazon Bedrock Guardrails says it filters harmful content and sensitive information "in user inputs or model responses". The refund goes out as a function call with an amount in it, which runs as soon as the model asks.
A customer who sounds sure of the numbers can argue the model past a prompt guardrail such as "never refund more than the order total". Someone asking on Hacker News how teams enforce permissions for agent tool calls put it as "what's your enforcement point that the agent cannot bypass?" Amiril's SDK sits between the model and the tool, in the agent's own process, and checks every call the model asks for.
The Amiril SDK wraps your agent's tools. Each time the model asks for a call, the SDK checks it against your published rules before the tool runs. A call that breaks a rule never reaches the tool, and the model gets a sentence back saying why.
The rules live in Amiril, and the SDK keeps a copy in the agent's memory, so a check makes no network request. Publish a change and every running process with that environment's API key has it within about a minute. Tightening a rule needs no redeploy. If Amiril can't be reached, the SDK goes on enforcing the last rules it had, and it saves them to disk so a restart doesn't lose them.
The SDK guides add AI agent guardrails to four kinds of agent:
create_agent, in Python or TypeScript (worked through for a transfer agent in how to block a bad tool call in LangGraph).This rule blocks a refund larger than what the customer paid. It reads the order total from the lookup_order call the agent made earlier in the same run.
@id("refund-within-order") @sentence("A refund of {amount} is more than the {paid} paid for order {order_id}") block ( agent == "support", tool == "issue_refund" ) unless { paid = latest(lookup_order{ args.order_id == call.args.order_id }).result.total; call.args.amount <= paid };
A refund of 40 on the 90 order runs as normal. When the model asks for 900, issue_refund doesn't run, and this comes back to the model as the tool's result:
The call to issue_refund was not performed. Rule refund-within-order blocked it: A refund of 900 is more than the 90 paid for order 1043. Do not retry this call with different arguments or achieve the same outcome another way; tell the user it was not performed.
A refund for an order the agent never looked up is blocked too, since paid has no value and the unless condition can't come out true.
A rule can also look back over a whole session, to allow one refund per order or to cap the total refunded.
Amiril drafts guardrails for AI agents from their past runs. It reads your agent's traces and compares each run with the same agent's earlier runs. Runs that share a problem are grouped into an issue.
When a rule could have stopped an issue's runs, Amiril drafts one with an AI model and tests the draft on past runs. It keeps the draft only if it catches some of the issue's runs and fires on at most one in a hundred of the agent's other runs. A kept draft shows on the issue's page as a rule suggestion, with a line such as "Would have blocked 4 of 5 runs". Create rule opens it in the editor, where you can change any value in it before you save. Saved, it starts in Shadow and blocks nothing until you switch it to Enforce.
You can write rules yourself too, as text or with the builder, or describe one in your own words and let Amiril write it. Claude and other assistants can write and test rules through Amiril's MCP server.
A published rule starts in Shadow. In Shadow it checks every call and records what it would have done, but it stops none of them. The rule's page counts the calls it would have fired on.
Test on past calls replays any version of a rule, a draft included, over the last day, week or month of real calls. It uses the same engine the SDK runs in your agent and lists each call the rule would have fired on, with the agent, the tool and the sentence.
A rule has its own mode in each environment. Switch it to Enforce in Development, try to get a 900 refund past it, and move Production over once the list holds only calls you meant to stop. From then on the rule's page counts what the SDK blocked and allowed. In shadow mode for AI agents, a test over 7 days of past calls shows a 20% discount cap would have blocked a salon's December offer, so the rule goes live at 25%.
A content filter reads text, such as the prompt and the reply, and looks for harm, personal data or banned topics. A tool call guardrail reads the call the model wants to make, with its name, its arguments and the calls earlier in the run. A filter has no order total to compare the refund amount with. In LLM guardrails vs tool call guardrails, a payment made without the payee check passes the content filters and is blocked by a rule that looks for an earlier verify_payee call.
The SDK checks tool calls in LangGraph, Google ADK and LiveKit Agents, and in a hand-written Python or TypeScript loop with no framework. For another framework you can write an adapter.
Amiril reads traces from OpenTelemetry, LangGraph, Google ADK, LiveKit, the OpenAI Agents SDK, CrewAI, the Anthropic SDK and the Claude Agent SDK. You can also upload a Langfuse export, history included.
Through Amiril's MCP gateway an agent can call only the tools you granted it, picked one by one or by level, from Read up to Destructive. When an agent hasn't used a tool in 30 days, Amiril makes an access suggestion to revoke it. We go through where each layer is enforced in enforcing AI agent permissions on tool calls, and check a reporting agent's SQL queries in AI agent security starts at the tool call.
Galileo, which Splunk now sells as Agent Observability, has AI agent guardrails of its own in Agent Control. A control there checks one selected field of a step, such as its input or output. The refund rule above compares the amount with the total an earlier lookup_order call returned.