Every defense so far has tried to make Aria decide well. You scoped down what it can touch, you taught it to treat incoming text as data rather than commands, and you put a human in front of the big actions. This chapter assumes all of that can still fail, because reasoning can always be talked into something, and wraps a second kind of defense around the agent: deterministic checks in plain code that block obviously bad actions before they ever run. The headline one is a hard cap that refuses any refund over $50, in code, regardless of what Aria decided.
A dumb belt under a smart agent
Chapter 4 was about defending Aria's judgment. This chapter is about not trusting it. That sounds contradictory until you see the two as layers. The reasoning defense is clever and context-aware, and like anything clever, it can be outsmarted by something cleverer. A guardrail in code is the opposite: it is dumb, it has no idea what the customer wrote, and that is exactly why you can rely on it. It checks a number against a limit, or a tool name against a list, and it does the same thing every single time.
Picture where these checks live. Aria sits in the middle, reading messages and deciding what to do. To its right are the real tools: the order lookup, the customer record, the refund. The guardrails are not part of Aria and not part of the tools. They sit in the narrow gap between them, a belt that every action has to pass through on its way out. Nothing Aria decides reaches a tool without crossing that belt first.
The thing to take from that picture is the position of the belt. It is downstream of all the reasoning and upstream of every irreversible action. By the time a check runs, Aria has already made up its mind, and the check gets the final word anyway. That ordering is the whole idea. You are not asking the agent to behave. You are making sure that even when it does not, the worst outcomes are simply not reachable.
The $50 cap, written down
The refund cap is the guardrail you will reach for first, because refunds are where Aria can do the most expensive damage. The rule is simple to say: Aria may issue a refund on its own up to $50, and anything larger is refused. The point of this section is that the rule has to live in code that runs, not in the prompt that asks Aria nicely. A line in the prompt is a suggestion the model can be talked out of. A check in code is a wall.
Here is the cap as a function the runtime actually calls before the refund tool is ever reached. It takes the refund the agent wants to make and returns a plain allow-or-block decision.
Those three habits are what separate a guardrail that runs from a comment that only hopes. The same checks live in the broader guardrails file alongside the other deterministic rules, annotated below.

Read the callouts top to bottom and you have the shape of the whole chapter. The cap is one constant and one comparison. The allowlist is a fixed set of tool names and a check that nothing outside it can ever run. The rate limit is a ceiling on how often a refund can even be attempted. None of these reads the customer's message. None of them knows or cares whether Aria was being clever or being manipulated. They look at the action itself and apply the same rule every time.
The cap does not care how clever the request was
The reason a coded cap matters is best seen against the failure it prevents. Imagine the message from Chapter 4 got through. A customer wrote in about order 4815, the $128.00 order from J. Okafor, and buried in the message was a convincing paragraph that talked Aria into deciding a full $128 refund was approved and should be issued right now. The reasoning defense did not catch it this time. Aria has decided to issue the refund. This is the moment the guardrail earns its place.

The decision is brutally simple, and that is the point. The check does not read the persuasive paragraph. It does not weigh whether the customer seemed sincere or whether the order really was lost. It compares 12800 cents against 5000 cents, sees that the first is larger, and refuses. The refund tool is never called. Whatever Aria was talked into upstream dies at a comparison it cannot argue with, and the action is routed to the human approval you built in Chapter 5 instead.
Rate limits, allowlists, and secrets
The cap is the headline, but it is one of several deterministic checks, and the others guard against failures the cap alone would miss. A rate limit caps how many refunds Aria can even attempt in a window, so a runaway loop or a flood of injected requests cannot drain the account fifty dollars at a time. An output allowlist means Aria can only ever call the small set of tools you named, so a confused or manipulated agent cannot reach for a tool you never intended it to have. And secrets, the API keys behind those tools, never pass through the model at all. Here is the rest of the guardrails file that the cap lives in.
The secrets handling is the quietest of these and the one people skip. The rule is that the model never sees a credential. Aria does not hold the Stripe key and paste it into a call. It asks the tool broker to run issue_refund, and the broker, which is ordinary code outside the model, looks up the key and makes the call. If a transcript leaks, or an injected message tricks Aria into repeating everything it knows, there is no key in there to leak. The same logic sandboxes the tools themselves: each runs with only the narrow access it needs, so even a tool called in error cannot reach past its own job.
It helps to watch one blocked action move through these checks rather than just read the file. The clip below follows the $128 refund on order 4815 from Aria's decision into the cap check and shows where it stops.
Trace the motion. Aria has already decided, the request travels to the cap check, the check compares 12800 against 5000, and the action stops dead at the gate. The arrow into the refund tool never lights, because the tool is never called. The block happens in the belt, between the decision and the action, which is the one place a deterministic check can do its job.
What the dumb checks catch that the smart one cannot
It is worth being precise about the division of labor between the reasoning defense from Chapter 4 and the coded guardrails here, because they catch genuinely different things. The reasoning layer is the only one that can tell a sincere customer from a manipulative one, since that judgment needs to read the message. The coded checks cannot read anything, but they hold firm exactly when the reasoning has been fooled. Neither one is enough alone, and the grid below shows why you want both.
| Reasoning (Ch 4) | Coded guardrails | |
|---|---|---|
| Polite, sincere-sounding refund scam | ✓ | ◐ |
| A $200 refund after Aria is fooled | ✗ | ✓ |
| Runaway loop firing refunds | ✗ | ✓ |
| Agent reaches for a tool it should not have | ✗ | ✓ |
| A leaked transcript exposing a key | ✗ | ✓ |
Read down the two columns and the pattern is clear. The reasoning defense wins the top row, the one that needs to read intent, and loses every row below it, because once Aria has been convinced, asking it to reason again does not help. The coded guardrails lose the top row, since a polite scam looks like a normal $40 refund to a cap that only sees the number, and win everything below. You ship both because the cases one misses are precisely the cases the other catches. That is what belt-and-suspenders means: the suspenders are there for the day the belt is talked loose.
- Guardrails are deterministic checks in plain code: same input, same answer, no model and no judgment involved.
- They sit in the belt between the agent and the tools, downstream of all reasoning and upstream of every irreversible action.
- The $50 refund cap is one constant and one integer comparison, and it refuses an over-cap refund no matter how cleverly Aria was talked into it.
- Add an output allowlist so Aria can only call the tools you named, and a rate limit so a runaway loop cannot drain the account.
- Keep secrets out of the model: the broker resolves the key at the boundary, so a leaked transcript leaks nothing.
- The reasoning defense catches what needs judgment; the coded checks hold firm exactly when the reasoning has been fooled. Ship both.
- Test a guardrail by assuming the agent is compromised and asking what is still impossible.


