Rifty Notes
Glossary

Guardrail

A guardrail is a deliberate constraint on what an agent may do — keeping a server read-only, blocking a destructive call, or capping spend — chosen to bound risk rather than because the capability is missing. It narrows the action space by policy and is enforced outside the model, so a misfire cannot cross the line you set.

How it works

A guardrail encodes a rule about what an agent is allowed to attempt, then enforces that rule outside the model's discretion. The model can reason its way to any action it likes; the guardrail decides what actually executes. The distinguishing feature is intent: the capability usually exists, and you withhold it on purpose.

Most guardrails sit at one of three points in the loop:

  • Before a call — an allow/deny check on the proposed tool invocation and its arguments. A write to production is refused even when the plan is sound.
  • On the surface — the capability is never exposed. A read-only database connection means "delete" is not a call the agent can make, not a call it is politely asked to avoid.
  • On the value — a bounded resource, such as a spend cap, request quota, or row limit, that caps the size of any single mistake.

The critical property is that enforcement lives below the model. A prompt instruction ("please don't drop tables") is a suggestion; a guardrail is a gate the request passes through whether or not the model cooperates. That separation is what makes it hold under prompt injection, hallucinated arguments, or an agent that has simply reasoned itself into a bad plan. A good guardrail also fails legibly: it denies the specific action, names the rule, and returns a message the loop can read and adapt to, rather than silently dropping the request.

Why it matters in an agent harness

Agents are stochastic. Over enough steps, one of them will propose something you do not want executed. Guardrails convert that certainty into a bounded, survivable event instead of an incident.

They do three concrete jobs. First, they shrink the blast radius: a read-only scope means the worst outcome of a confused agent is a wasted turn, not lost data. Second, they preserve reversibility by keeping irreversible actions — deletes, payments, sends, deploys — behind an explicit boundary, so most of what the agent does can be rolled back. Third, they make behavior legible: every denied action is a logged, named event, which turns "the agent did something weird" into a specific rule that fired at a specific step.

Guardrails are also how you grant autonomy without granting recklessness. You can let an agent run unattended precisely because the set of things it can do is smaller than the set of things it can think of. The constraint is what earns the freedom.

Guardrail vs sandbox

Both limit damage, but they answer different questions, and confusing them leaves gaps.

GuardrailSandbox
QuestionMay this action happen?Where can its effects reach?
MechanismPolicy that narrows the action spaceIsolation that contains the environment
Enforced byAllow/deny checks, scoped tools, capsProcess, container, or network boundary
Fails towardDenied action, legible messageContained blast, nothing escapes

A guardrail decides an action is off-limits; a sandbox decides that even a permitted action cannot touch anything outside its box. You want both: the guardrail stops the calls you can name in advance, and the sandbox contains the ones you did not anticipate. Treating either as a substitute for the other is a common way to end up with a false sense of safety.

The Rifty take

We treat guardrails as a design choice, not a safety afterthought. The most useful harness usually exposes fewer capabilities than the agent could handle, because a narrower action space is easier to reason about, audit, and trust unattended. We accept that this occasionally blocks a legitimate action and forces a human decision — that friction is the price of reversibility, and it is a price worth paying. A guardrail you can state in one sentence and enforce below the model is worth more than a clever prompt that asks the agent to behave.

Common failure modes

  • Prompt-level "guardrails." Rules that live only in the system prompt are advisory. Anything an agent can talk itself out of is not a guardrail; enforce below the model.
  • Guarding the plan, not the call. Checking intent while leaving the raw tool exposed lets a mis-argued or injected call slip through. Constrain the actual capability.
  • Illegible denials. A guardrail that fails silently or with an opaque error traps the agent in a retry loop. Return the rule that fired and why.
  • Over-guarding into uselessness. Blocking so much that the agent stalls on routine work pushes operators toward disabling the guardrail entirely. Scope to the irreversible and the expensive.
  • Static scope, drifting tools. New tools added later inherit no constraint. Tie guardrails to the tool surface so additions are denied by default, not permitted by omission.
  • Guardrail without containment. Relying on allow/deny alone, with no sandbox behind it, means the first unanticipated action has full reach.

Frequently asked questions

How is a guardrail different from just prompting an agent to behave?

A prompt instruction is a suggestion the model can reason its way past, especially under prompt injection or a hallucinated plan. A guardrail is enforced below the model — an allow/deny check, a scoped tool, or a hard cap — so the action is blocked whether or not the agent cooperates.

Do guardrails replace sandboxing?

No. A guardrail decides whether an action may happen; a sandbox contains where a permitted action's effects can reach. Guardrails stop the calls you can name in advance, sandboxes contain the ones you did not anticipate. Robust harnesses use both, since either alone leaves a predictable gap.

What should a guardrail actually protect?

Prioritize the irreversible and the expensive — deletes, payments, sends, deploys, and unbounded spend or quota. These are the actions where a single stochastic misfire becomes an incident. Guarding routine, reversible work too tightly just stalls the agent and tempts operators to switch the guardrail off entirely.

Where in the agent loop should a guardrail sit?

As close to the actual call as possible. Guard the tool invocation and its arguments, not just the model's stated plan, since a mis-argued or injected call can diverge from the reasoning. Better still, narrow the tool surface itself so the dangerous capability is never exposed as an option.

Can guardrails be too strict?

Yes. Over-guarding blocks legitimate actions, stalls routine work, and pushes operators toward disabling the constraint — the worst outcome. Scope guardrails to genuinely risky actions, return a legible message naming the rule that fired, and let most reversible work proceed so the agent stays useful unattended.

Related glossary terms.

Guardrail