All guides

    Guide

    What are AI agent guardrails, and which ones stop harmful actions?

    Updated

    Short answer

    AI agent guardrails are controls that limit what an agent reads, says and does. Input and output filters screen the text going into and coming out of the model. Coding agents run commands, edit files and push code with a developer's credentials, so the guardrails that stop harm check each action against the task before it runs. They sit outside the agent, where it can't switch them off.

    Guardrails for words, guardrails for actions#

    Most guardrail talk is about words. Input guardrails screen what goes into the model (prompts, retrieved documents). Output guardrails screen what comes out (toxic text, leaked data in a reply).

    Those matter for chatbots. A coding agent does more than talk. It runs shell commands, edits files, pushes to git and calls APIs with the developer's credentials.

    So there's a second kind: action guardrails. They check what the agent is about to do, not the sentence it wrote about it. A harmful action is harmful whether or not the prompt looked clean.

    What OWASP says about the risk#

    OWASP files this under excessive agency (LLM06), including the case where an application \"fails to independently verify and approve high-impact actions\".

    Its mitigation is worth reading twice: \"Implement authorization in downstream systems rather than relying on an LLM to decide if an action is allowed or not.\" A guardrail the model can talk itself out of isn't a guardrail.

    What each control does and doesn't stop#

    ControlWhat it stopsWhat it misses
    Input and output filtersObvious bad prompts, bad repliesActions that follow from clean-looking input
    Permission rules and allowlistsTools and commands you namedVariants you didn't name; whatever an allowed tool can do
    SandboxReach: files and network outside the boundaryAnything inside the boundary; tools that run outside it
    Human approvalHigh-impact actions, when someone reads themMost prompts, because people approve them
    Per-action check against the taskActions that don't fit what was askedLeaks spread across several calls, a determined attacker

    Permission rules and allowlists#

    Claude Code's permission rules are real controls. Anthropic's docs say they \"control which tools Claude Code can use and are evaluated before any tool runs\".

    They match what the action looks like, not what it does. An allowed git command can still push to the wrong place, and a deny on one way to delete a directory doesn't cover another way to write the same delete.

    Use them for the clear cases, and keep the list short enough to audit. For more, see permissions vs hooks vs sandbox.

    Sandboxes#

    A sandbox bounds reach. Anthropic's docs say the OS enforces the boundary, so it \"holds regardless of what the model chose to run\". That's a strong property, and it's why a sandbox belongs in every rollout.

    It has edges. The same docs say the sandbox \"covers shell commands only\": file tools, MCP servers and hooks run outside it. Inside the boundary, a sandbox doesn't ask whether the action fits the task.

    More in sandboxing Claude Code and Codex.

    Human approval and its limits#

    Approval prompts are the default guardrail, and they fail in a predictable way. Anthropic says prompting \"leads to approval fatigue, where people stop paying close attention to what they're approving\", and users accept 93% of prompts anyway.

    Its controlled study is harsher. Across 1,053 paid testers, \"the testers caught the dangerous command just 13.6% of the time\".

    Agents take a lot of actions: 145 per session on average, and over 1,000 on long ones. Nobody reads 145 prompts carefully. Keep humans for the small set of actions you can't undo, like publishing a package or force-pushing, and let a check handle the rest.

    Checking each action against the task#

    The same command can be fine or harmful depending on intent. Deleting a test file is a cleanup in one session and a cover-up in another. A rule on the command text can't tell them apart; a check that knows what the session was asked to do can.

    That's the guardrail that fills the gap between rules and humans: look at the pending action, compare it with the task, and allow, ask or block before it runs. For what a rule can and can't decide alone, see rules vs context.

    Where Harden fits#

    Harden Agentic Integrity Foundation (AIF) is an action guardrail. It runs on the developer laptop, outside the agent, at the agent's pre-execution hook. Every command, file edit and push is checked against the session's intent before it runs.

    Decisions are made locally, and nothing leaves the machine. In internal use, verdicts take about 28 ms, and 0.25% of 24,809 decisions were wrong hard blocks. One policy covers every agent, and if the check can't run, the action doesn't run.

    It's a layer, not a perimeter. It doesn't replace least privilege, scoped credentials or egress policy, and exfiltration spread across several calls is the hard case.

    How to roll guardrails out without slowing developers#

    • Start watch-only. Log every decision, enforce nothing, and see what agents actually do for a couple of weeks.
    • Fix the cheap things first. Scoped, short-lived credentials, a sandbox for shell commands, read-only agent config.
    • Enforce the clear cases. Secrets reaching a network call, recursive deletes at the root, force-pushes to the default branch.
    • Gate the irreversible. Publish, shared push, deploy, payments, external email. See irreversible actions.
    • Drop prompts the check now covers. Developers stop clicking yes on things a policy already decided.

    Push the policy through the MDM you already run. Developers shouldn't have to configure anything.

    FAQ

    Related questions

    What is the difference between input, output and action guardrails?

    Input guardrails screen what goes into the model, and output guardrails screen what comes back. Action guardrails check what the agent is about to do, such as a command, file edit or push, before it executes. For coding agents, the action is where the damage happens.

    Are permission rules enough as guardrails?

    They're a good first layer for clear cases, but they match what a command looks like, not what it does. An allowed tool can still do harm, and a deny on one form of a command can miss another. Pair them with a sandbox and a per-action check.

    Do human approval prompts work as a guardrail?

    Only for a small number of high-impact actions. Anthropic reports users accept 93% of permission prompts, and in its study of 1,053 testers people caught a dangerous command 13.6% of the time.

    How do I add guardrails without slowing developers down?

    Start in watch-only mode so you can see what agents do before enforcing anything. Then enforce the clear cases, gate the few irreversible actions, and remove prompts that a check now covers.

    Can a sandbox replace action guardrails?

    No. A sandbox limits what a shell command can reach, but it doesn't judge whether an action inside the boundary fits the task, and file tools, MCP servers and hooks run outside it. Use both.

    Sources

    1. LLM06:2025 Excessive Agency - OWASP Gen AI Security Project
    2. Sandboxing - Claude Code Docs
    3. Claude Code auto mode - Anthropic Engineering
    4. Auto mode is now the default in Claude Code - Anthropic

    Start free at harden.run

    Full Enterprise access, free for 60 days: unlimited developers, custom policies, centralized visibility, no commitment.