Governance

How to Prevent an AI Agent from Going Rogue (What Actually Works in Production)

Preventing an AI agent from causing real damage isn't about better prompts — it's about a deterministic layer between the agent and the system it can touch. Here's the pattern that works.

·4 min read
Key Takeaways
  • 01LLM-based guardrails cannot reliably catch failures caused by the LLM itself.
  • 02Fail-closed means: if governance is uncertain, the action does not execute.
  • 03Every agent action should produce a cryptographically signed receipt that can be audited later.
  • 04The useful unit of governance is the action, not the prompt or the response.
  • 05Prompt injection usually arrives through retrieved content, not user input — defend the output, not the input.

"Going rogue" is a marketing phrase. In production, what it actually means is narrower: the agent took an action that caused real damage — sent, wrote, deleted, paid, published — and the system around it didn't catch it in time.

Preventing this is a solved problem, but not in the way most articles suggest. Better prompts don't solve it. "AI safety training" doesn't solve it. More sophisticated LLM guardrails don't solve it, because the failures that matter most happen when the LLM itself is the thing that's compromised.

Here is what actually works, and why.

The core insight: don't ask the LLM to police itself

Most "AI safety" measures are implemented as additional LLM calls:

  • "Ask a second LLM whether the first LLM's response is safe."
  • "Run the output through a fine-tuned classifier."
  • "Add a long system prompt with 'DO NOT do X.'"

All three share the same failure mode: when the LLM is confused, jailbroken, or prompt-injected, its ability to evaluate its own output is compromised at the same time. The second LLM is also confused by the same injected content. The classifier is trained on distributions it's now outside. The long prompt is being ignored by the same instruction-follower you wrote it for.

This is why, in production, the governance layer that works is deterministic — rule-based, external, and cryptographically bound.

The pattern: action-level deterministic governance

Think of an agent not as a chat, but as a process that emits actions. Each action is a discrete unit: "send this email," "write this file," "post this request," "execute this command."

Every action flows through a governance layer before execution. The layer does three things:

  1. Authenticate. The action must arrive with a valid cryptographic signature from the agent that produced it. No signature, no execution. This stops ghost processes, replayed requests, and side-channel injection.

  2. Evaluate. The action is scored against deterministic policies. Not an LLM — actual rules. Risk tiers, allowlists, ACLs, budget caps, output-pattern matches for leaked secrets. Each rule returns a decision with a reason.

  3. Enforce. Fail-closed. If the layer is uncertain, the action does not execute. Every decision — allow or deny — produces a signed receipt that can be audited later.

This is what a kernel does. It's the same architectural pattern operating systems have used for fifty years: privileged code sits between user processes and real resources, and enforces policy deterministically.

What "fail-closed" actually means

Fail-closed is the hardest part for teams to accept, because it means the agent sometimes fails to act. An unreliable governance layer that always says yes is indistinguishable from no governance at all.

Concretely, fail-closed means:

  • If the policy engine cannot reach a verdict, deny.
  • If the signature is malformed, deny.
  • If a budget check times out, deny.
  • If the action matches any policy that says deny, deny — even if another says allow.

This produces a system where "the agent didn't do the thing" is sometimes the correct outcome. That's the trade. In exchange, you get a system where "the agent did a thing that shouldn't have been done" never happens — or when it does, you have a signed receipt of exactly why the layer let it through, so you can close the gap.

The specific rules that matter most

A minimal governance ruleset in production includes:

  • Secret-pattern egress filter. Responses are scanned for patterns matching API keys, private keys, bearer tokens, and configured sensitive strings. Fail-closed on match.
  • Action allowlist. Agents may perform only actions from an explicit list. Everything else requires approval.
  • External-communication tier. Emailing outside the org, posting to public channels, making outbound API calls to untrusted domains — all require a higher authorization tier.
  • Budget cap. Every agent has a hard spend limit per day, enforced at the kernel level, not the agent level.
  • Replay protection. Every action carries a nonce + timestamp. Duplicate nonces are rejected. Expired timestamps are rejected.
  • Destructive-action approval. Any action with irreversible effect (delete, pay, publish to public) requires a human approval tier or a cryptographically-attested automated policy.

None of these are LLM calls. All of them are deterministic. Each one is auditable after the fact.

Where prompt injection actually comes from

Most documentation on prompt injection shows examples of user input carrying instructions. In production, that's the less common case.

The common case is that the agent retrieves content from the web, a document, or another agent's output — and that content carries instructions. The agent's "user" is benign. The attacker is some third party who published a page the agent fetched, or planted a comment the agent parsed.

Defending against this at the input layer is almost impossible, because there's no bright line between "content to read" and "content to obey." The practical defense is at the output layer: scan the agent's action for the signatures of attacker-controlled behavior (secret leakage, unexpected outbound requests, commands outside the allowlist). That's where the deterministic layer earns its keep.

What "not going rogue" actually looks like

A governed agent under Sift produces an action. The kernel evaluates it. If allowed, the action executes and a signed receipt is logged. If denied, the receipt records the rule that triggered the deny and why. The agent is told — but more importantly, the audit log records — exactly what happened.

The agent never "goes rogue." It emits actions. Some of them are blocked. The system remains governable, auditable, and recoverable even when the LLM itself is confused.

That's the whole shape of the solution. Everything else — better prompts, careful tool definitions, improved models — are useful inside this envelope. They are not substitutes for it.

Run your agents under Sift.

Deterministic governance. Cryptographic receipts. Fail-closed by default.

Related

More in Governance