Stateful Guardrails for AI Agents Explained: Inspecting Prompts and Tool Calls Before They Run
A prompt-injection filter that reads one message at a time is blind to the attack that matters most for agents: the one assembled over ten turns, or smuggled in through a web page the agent fetched three steps ago. Each fragment looks harmless. The harm only exists in the sequence, and in the tool call it finally produces. Stateful guardrails for AI agents close that gap by judging each new prompt and each proposed tool call against the system prompt and the session so far, before anything executes. On November 29, 2026, AWS put this idea into a gated preview of Amazon Bedrock Guardrails, including a Security Threat Check aimed squarely at tool calls. You will leave this post knowing what “state” a guardrail must carry, where a pre-execution check sits in the agent loop, what it costs in latency and money, and why it complements rather than replaces deterministic policy.
What this covers: the failure of stateless filters, the anatomy of session state, Bedrock’s verified preview facts, cost and false-positive math, policy engines, open-source options, and a defence-in-depth reference architecture.
Context and Background
For the first wave of LLM applications, guardrails were per-message classifiers. A user message went in, a classifier scored it for jailbreak or toxicity, and the application blocked or passed it. The model response got the same treatment on the way out. That design matched chatbots well: one human, one turn, one answer, and the main risk was a harmful string reaching a screen.
Agents broke the assumptions. An agent plans over many turns, reads untrusted content from tools, keeps memory, and emits actions: shell commands, HTTP requests, database writes, payments. The OWASP GenAI Security Project still ranks prompt injection as the number one risk in its 2026 LLM Top 10, and it moved Excessive Agency up to third place. The reporting around that release framed the lesson bluntly: stop trying to build a model that cannot be fooled, and limit the damage instead. We covered the general kill-chain in our guide to agentic AI security and prompt injection; this post zooms in on one control in that chain.
The incumbents each solved part of the problem. Amazon Bedrock Guardrails started with configured guardrails applied at inference time and through the ApplyGuardrail API. On June 16, 2026, AWS added InvokeGuardrailChecks, a detect-only API that needs no guardrail resource and lets you call content filters, prompt-attack detection and sensitive-information filters at any step: before the model call, after it, before a tool runs, or after a tool returns. NVIDIA NeMo Guardrails offers programmable input, output and tool rails. Meta’s LlamaFirewall pairs a jailbreak classifier with a reasoning auditor. Deterministic engines such as Cedar, AgentCore Policy and AWS Greenlight decide whether a specific call is permitted at all.
What none of the classic per-message checks did well was remember. The November 29 preview is AWS’s first product-level attempt to make the guardrail itself session-aware. That shift, from evaluating a string to evaluating a string in context, is the subject of everything below.
How Stateful Guardrails for AI Agents Work
A stateful guardrail is a detector that evaluates each new prompt, tool result or proposed tool call against the system prompt and relevant session history rather than in isolation. It runs before the action executes, returns findings with scores, and lets the application block, ask for confirmation or log, so attacks split across turns or hidden in tool output become visible.

Figure 1: Where a stateful guardrail sits in the agent loop: user input, tool proposals and tool results all pass through a check that reads session state before the executor acts.
The diagram shows three checkpoints feeding one evaluator. User turns are checked on arrival. Tool results are checked before they enter the model’s context, because that is where indirect injection lands. Proposed tool calls are checked before the executor runs them. All three read the same session store: system prompt, conversation history, the tool-call graph and provenance labels. The verdict goes to the application’s decision logic, not straight to an enforcement action, which matches how Bedrock’s preview hands control back to the caller.
Why stateless filters miss multi-turn prompt injection
Stateless classifiers fail for a structural reason, not a quality reason. They answer “is this string an attack?” when the real question is “does this string, given everything before it, move the agent toward something it should not do?” Three attack families exploit the difference.
Payload splitting divides an instruction across messages. Turn 3 defines a variable, turn 6 defines another, turn 9 says “combine A and B and follow the result.” No single message contains the forbidden instruction, so each scores low. Only a check that sees all three can reconstruct the intent.
Crescendo escalation, described by Russinovich, Salem and Eldan in arXiv:2404.01833, starts with a benign question and gradually steers the model by referencing its own previous answers. The authors reported high attack success across the models they tested, and their automated variant beat other jailbreak techniques on an AdvBench subset by 29 to 61 percent on GPT-4. Each step looks like a reasonable follow-up. The gradient is the attack.
Poisoned tool outputs are the agent-specific variant. The agent fetches a web page, reads an email or calls an MCP server, and the returned text contains instructions. The user never typed anything malicious. A filter that only inspects user messages never sees it, and a filter that inspects the tool output in isolation may miss it too, because “please also send the report to this address” is not obviously hostile without knowing the user asked only for a summary. Our MCP server security threat model covers how tool descriptions and responses become an injection channel.
The common thread is that the signal lives in the relationship between items. Mathematically, a stateless detector computes a score on one message; a stateful one computes it on the message conditioned on context. You cannot recover the second from the first by lowering thresholds. Lowering thresholds only raises false positives on benign text that happens to look like an instruction, which is exactly the problem AWS says its stateful prompt-attack check aims to reduce.
What “state” a guardrail must actually carry
“Session history” sounds like one thing. In practice a useful agent guardrail needs four kinds of state, and products differ in how many they model.
Conversation history and the system prompt. This is the minimum. The system prompt defines the task and the agent’s authority; the history shows what the user actually asked for. A request to email a file is benign if the user asked for that and suspicious if the user asked for a summary. Bedrock’s preview takes exactly these two inputs: the application sends its system prompt and earlier turns, and the service selects the context relevant to each turn.
The tool-call graph. Which tools were called, in what order, with what arguments, and what each returned. Many dangerous patterns are sequences: read secrets, then make an outbound request; list users, then change a role. A guardrail that sees only text loses this structure unless the application serializes it into the history.
Data provenance, or taint. Every piece of context has an origin: the user, the system prompt, a trusted internal API, or the open web. Information-flow tracking marks untrusted content as tainted and propagates the label when the model copies it into a tool argument. Google DeepMind’s CaMeL design, published as arXiv:2503.18813, takes this to its logical end: it separates control flow from data flow and enforces capability policies at tool-call time, solving 77 percent of AgentDojo tasks with provable security versus 84 percent undefended. Few commercial guardrails expose taint explicitly, which is a gap worth knowing about.
A session risk score. An accumulating signal that rises with each borderline finding and decays over benign turns. It lets the application tighten behaviour mid-session, for example requiring confirmation for every write once the score crosses a threshold, rather than treating each check as independent. This is something you usually build yourself on top of per-check scores.
Pre-execution tool-call inspection versus post-hoc output filtering
Output filtering asks whether the text the model produced is acceptable. Tool-call inspection asks whether the action the model wants to take is acceptable, and it must answer before the side effect happens. The difference is irreversibility. A toxic sentence can be suppressed after generation; a DELETE against production or a POST that exfiltrates a token cannot be recalled.
So the check belongs on the critical path between the model’s tool-use output and the executor. In frameworks such as the Bedrock Converse API, LangGraph or the Strands Agents SDK, that means intercepting the tool-use block, sending the proposed name and arguments plus session context to the evaluator, and only invoking the tool if the verdict allows it. The AWS announcement describes exactly this placement: call the security threat check before a tool runs, then stop the call, ask the user to confirm, or log it. The application decides.
Post-hoc filtering still has a role. Tool results should be scanned before they re-enter the model context, and final answers before they reach a user. But anything that changes the world should be gated before it runs, and that gate is where state pays off most.
What Bedrock Guardrails Security Threat Check Actually Is
AWS announced stateful guardrails for Amazon Bedrock Guardrails on November 29, 2026, the weekend before re:Invent. The facts below come from the official What’s New post and Bedrock documentation, re-read on December 4, 2026. Anything sourced only from third-party coverage is marked as reported.
| Item | Verified status (as of 2026-12-04) |
|---|---|
| Announcement date | November 29, 2026 |
| Availability | Gated preview for allowlisted customers; access via AWS account team or a preview sign-up page |
| Regions | US East (N. Virginia) and US West (Oregon) |
| API surface | Two new checks on the InvokeGuardrailChecks API |
| Inputs | Application’s system prompt plus earlier turns; the service selects relevant context per turn |
| Check 1 | Stateful prompt attack |
| Check 2 | Security threat check |
| Enforcement | Detect-only; application blocks, asks for confirmation, or logs |
| Pricing | Not published in the announcement or on the Bedrock pricing page |
| Detection rates, latency, history limits | Not published |
The two checks
The stateful prompt-attack check targets two things AWS names directly: reducing false positives on benign instructions that resemble attacks, and detecting attacks spread across turns or hidden in tool results. The first goal matters as much as the second. A stateless jailbreak detector often flags “ignore the previous formatting and use a table,” because it matches a surface pattern. With the system prompt and history in view, the same phrase can be recognised as an ordinary user preference.
The security threat check reviews user prompts and agent tool calls for three classes of problem, per the announcement: connections to domains and IP addresses that AWS threat intelligence marks as malicious; commands that expose credentials or escalate privileges; and tool calls that violate a security principle given the session so far. The first class is reputation lookup. The second is pattern-and-semantics analysis of commands, such as reading a credentials file or attaching an admin policy. The third is the genuinely stateful one, since “violates a security principle given the session” can only be judged with history.
AWS’s own framing is careful. Third-party analysis of the announcement notes that AWS does not promise a request with no finding is safe to execute, and no detection or false-positive figures were published. Coverage of the December 3 keynote reported that Security Threat Check was featured in the security segment; we did not find an official transcript confirming the wording.
How it relates to InvokeGuardrailChecks
The June API is the foundation. Its public API reference shows a request with two required top-level fields, checks and messages, where checks can include contentFilter, promptAttack and sensitiveInformation. The response returns per-check results with severity or confidence scores and a usage block counting text units per check. The user guide describes scores between 0 and 1 and leaves thresholds to you.
As of this writing, the public API reference does not show fields for the system prompt, session history or the two new checks. Preview documentation may differ, and allowlisted customers get it through the preview channel. Do not write production code against guessed field names; wait for the preview docs or general availability.
The detect-only model is a deliberate design choice. Configured guardrails applied during inference can return a blocked response directly. InvokeGuardrailChecks returns evidence and leaves the decision to you, which suits agents because the right response to a risky tool call varies: block a credential read outright, ask a human about an unusual outbound domain, log a borderline command in a sandbox.
Deeper Analysis: Latency, Cost and False-Positive Economics
A pre-execution check is a synchronous network call on the agent’s critical path. Before adopting stateful tool call inspection at scale, model three budgets: added latency, evaluation cost and the human cost of false positives.

Figure 2: Sequence of a gated tool call: the model proposes an action, the application sends it with session context to the guardrail, and only an allow verdict reaches the executor.
The sequence shows why latency compounds. The model finishes generating a tool-use block; the application serializes the proposal plus context; the guardrail evaluates; the application decides; then the tool runs. If a result returns, it can pass through a second check before re-entering the context. Every tool call in a plan now carries one or two extra round trips.
Latency budget (illustrative)
AWS has not published latency for the stateful checks, so treat the following as illustrative. Suppose a check adds 150 ms at median. An agent that makes eight sequential tool calls per task adds 1.2 seconds of wall-clock time. If the stateful variant is slower because it reasons over more context, say 400 ms, the same task adds 3.2 seconds. For a chat agent with a three-to-five-second response budget, that is the difference between invisible and noticeable.
Three techniques keep this in check. First, run cheap deterministic checks before the model-based one: a policy engine denial costs microseconds and short-circuits the expensive call. Second, parallelize where safety allows. Scanning a tool result can run alongside other independent work, but a pre-execution gate on a write cannot be skipped or run after the fact. Third, tier the checks by risk. A read-only search against an internal index may skip the stateful check entirely, while any tool that writes, sends or spends always goes through it.
Cost model: how history size drives the bill
Pricing for the stateful checks is unpublished. The closest public reference is current InvokeGuardrailChecks list pricing on the Bedrock pricing page: $0.07 per 1,000 text units for content filters, $0.08 for the prompt-attack filter, and $0.10 for sensitive-information filters, where a text unit holds up to 1,000 characters. The key unknown is how many text units a stateful check bills when it reads history.
The script below models one 20-turn session with eight tool calls, a 6,000-character system prompt, 1,500-character turns, 500-character tool proposals and 4,000-character tool results. All sizes are illustrative, and the prompt-attack price is a proxy, not the preview’s price. It compares three billing behaviours: delta (only the new item is billed), window (system prompt plus a 12,000-character recent window), and full (the whole history every time).
import math
PRICE_PER_UNIT = 0.08 / 1000 # proxy: InvokeGuardrailChecks prompt-attack list price
SYSTEM, TURN, PROPOSAL, TOOL_OUT = 6_000, 1_500, 500, 4_000 # characters, illustrative
TOOL_TURNS = {3, 5, 8, 10, 13, 15, 18, 20} # 8 tool calls in 20 turns
WINDOW = 12_000 # chars of recent history kept
def units(chars): # 1 text unit = up to 1,000 characters
return math.ceil(chars / 1_000)
def session(strategy):
history, billed, checks = SYSTEM, 0, 0
events = []
for t in range(1, 21):
events.append(TURN)
if t in TOOL_TURNS:
events += [PROPOSAL, TOOL_OUT]
for size in events:
history += size
checks += 1
if strategy == "delta": # stateless: only the new item
billed += units(size)
elif strategy == "window": # system prompt + recent window
billed += units(SYSTEM + min(history - SYSTEM, WINDOW))
else: # resend everything every time
billed += units(history)
return checks, billed, billed * PRICE_PER_UNIT
for s in ("delta", "window", "full"):
checks, billed, cost = session(s)
print(f"{s:6s} checks={checks} units={billed:5d} "
f"per-session=${cost:.4f} per-100k-sessions/day=${cost*100_000:,.0f}")
Running it gives 36 checks per session in every case, but very different bills. Delta billing uses 80 text units, about $0.0064 per session or $640 per day at 100,000 sessions. The windowed approach uses 611 units, about $0.049 per session or roughly $4,900 per day. Full-history billing uses 1,414 units, about $0.113 per session or roughly $11,300 per day, which is 17.7 times the delta cost.
The lesson is about shape, not the exact figures. If a stateful check bills for the context it reads, cost grows roughly quadratically with session length, because each check rereads a longer history. AWS says the service selects the relevant context per turn, which may bound this, but until pricing is published you should assume history size matters. Keep system prompts tight, summarise old turns, and avoid pasting huge tool outputs into history verbatim. Those habits also cut model inference cost, which dwarfs guardrail cost in most deployments.
False-positive economics
The cost that usually sinks guardrail rollouts is not the API bill. It is the people who handle false positives. Detection runs against a very low base rate: almost every tool call in a legitimate deployment is benign.
Take an illustrative fleet making 1,000,000 tool calls per day, with an attack prevalence of 0.1 percent, a detector true-positive rate of 95 percent and a false-positive rate of 1 percent. Bayes’ rule gives a precision of about 8.7 percent: more than ten benign calls are flagged for every real attack. That is roughly 9,990 false alarms per day. If each one routes to a human confirmation that takes 30 seconds, that is about 83 person-hours daily. Cut the false-positive rate to 0.1 percent and precision rises to about 49 percent, false alarms fall to 999 per day, and review time to roughly 8.3 hours.
This is why AWS’s stated goal of fewer false positives on benign instructions is commercially important, and why you should not route every flag to a human. Use the score and the tool’s risk tier together. A high-risk action with a moderate score asks for confirmation; a low-risk action with the same score is logged and allowed; any action with a very high score is blocked. Measure precision on your own traffic before turning on blocking, because published benchmarks rarely match your tool mix.

Figure 3: A score-plus-risk-tier decision flow turns detect-only findings into proportionate actions instead of blanket blocking.
The flow in Figure 3 starts with a deterministic policy check, which can deny outright. Calls that pass policy go to the stateful guardrail. The returned score is combined with the tool’s risk tier and the session risk score. The outcome is one of four actions: allow, allow and log, ask for human confirmation, or block and end the session. Every path writes an audit record, because a detect-only system is only as good as the evidence it leaves behind.
Guardrails vs Policy Enforcement: Where Deterministic Controls Fit
Guardrails and policy engines answer different questions. A guardrail asks whether something looks malicious or unsafe. A policy engine asks whether this principal is permitted to take this action on this resource right now. The first is probabilistic and adaptive; the second is deterministic and auditable. Agents need both, and confusing them is the most common architectural error in this space.
Deterministic policy: Cedar, AgentCore Policy and Greenlight
AWS has spent 2026 building the deterministic side. In August it described temporal, session-level policies for Amazon Bedrock AgentCore, powered by Dogwood, an Apache-2.0 policy language built on Cedar. Dogwood adds constructs for rate limits, time windows, prerequisite steps and escalation triggers. Examples from the AWS post include blocking a transfer unless a value matches one returned by an earlier call, and blocking purchases once cumulative spend reaches a budget. These policies are enforced at the gateway, outside the agent’s code, deny-by-default.
At re:Invent, AWS previewed Greenlight, which drafts such policies from written procedures and observed tool calls and checks them with automated reasoning before deployment. Our explainer on AWS Greenlight and automated-reasoning policy enforcement covers that in depth.
Notice that Dogwood temporal policies are also stateful. They read session event history. The difference is what they read and how they decide. A temporal policy knows exactly what “an earlier call returned value X” means and evaluates a rule with no ambiguity. A stateful guardrail reads natural language and infers intent. Policy catches what you anticipated and wrote down. The guardrail catches what you did not anticipate but which looks like an attack.
Identity scoping limits the blast radius
Neither control helps much if the agent holds broad credentials. If the executor runs with an administrator role, a single missed detection becomes a full compromise. Scoped, short-lived credentials make every other layer cheaper, because a missed detection can only do what the token permits. Our guides to delegated authorization for AI agents and least-privilege agent credentials with STS GetScopedCredentials show the mechanics.
The layering logic is simple. Identity caps the worst case. Policy blocks known-bad patterns deterministically. The stateful guardrail catches novel or disguised attacks within what policy permits. Sandboxing contains whatever slips through all three.
Mapping to OWASP risk lists
The table maps the controls discussed here to the OWASP Top 10 for Agentic Applications, released December 2025, and to the 2026 LLM Top 10 ranks reported at its August 2026 release.
| Risk | Primary control | Role of a stateful guardrail |
|---|---|---|
| ASI01 Agent Goal Hijack / LLM Top 10 #1 Prompt Injection | Stateful prompt-attack detection, taint tracking | Primary detector for multi-turn and indirect injection |
| ASI02 Tool Misuse | Policy engine plus pre-execution inspection | Flags tool calls inconsistent with the session’s task |
| ASI03 Identity and Privilege Abuse | Scoped credentials, deny-by-default policy | Flags privilege-escalation commands; cannot enforce scope |
| ASI05 Unexpected Code Execution | Sandboxing, command allow-lists | Flags credential-exposing or escalating commands |
| ASI06 Memory and Context Poisoning | Provenance labels, memory write review | Scans tool results and memory reads before they enter context |
| LLM Top 10 #3 Excessive Agency | Least privilege, human approval for high-impact actions | Supplies the risk signal that triggers confirmation |
| LLM Top 10 #2 Sensitive Information Disclosure | PII filters, egress controls | Threat intelligence on outbound domains; PII checks on arguments |
The pattern is consistent: the guardrail is a detector and signal source, while enforcement lives in identity, policy and isolation.
Open-Source Alternatives for Agent Runtime Security
You do not need Bedrock to build stateful inspection. Several open-source projects cover parts of the problem, though each puts the boundary in a different place.
NVIDIA NeMo Guardrails is the most configurable. Version 0.25.0, the latest listed in NVIDIA’s release notes, adds a hooks server that checks tool calls before agents such as Claude Code, Codex or NeMo Relay run them, allowing or blocking by tool name and arguments. Its IORails component supports per-tool checks on arguments and results using regular expressions, CEL expressions or an LLM judge, and a /v1/checks endpoint runs these checks without generation. State is whatever you pass in. NeMo Guardrails gives you the hook points; you decide how much history the judge sees.
Meta LlamaFirewall, described in arXiv:2505.03574, combines three components. PromptGuard 2 is a jailbreak classifier for inputs. AlignmentCheck, which the paper calls Agent Alignment Checks, is a chain-of-thought auditor that inspects the agent’s reasoning for injection and goal misalignment, which makes it inherently trajectory-aware. CodeShield is an online static-analysis engine for generated code. The authors describe the alignment auditor as experimental. Meta’s Llama Guard 4, a 12-billion-parameter safety classifier published on Hugging Face, covers content-safety classification of prompts and responses rather than tool-call intent.
Research designs such as CaMeL show where the field may go: instead of detecting bad intent, they make it structurally impossible for untrusted data to change control flow. The cost is task coverage and engineering complexity, as the 77-versus-84 percent AgentDojo result illustrates.
| Option | State handled | Tool-call gating | Deployment |
|---|---|---|---|
| Bedrock stateful guardrails (preview) | System prompt plus session history, context selected by service | Yes, via security threat check | Managed API, two US regions, allowlist |
| Bedrock InvokeGuardrailChecks (GA) | Messages you send | Yes, if you call it before tools | Managed API, seven regions |
| NeMo Guardrails 0.25.0 | Whatever context you pass to rails | Yes, hooks server and per-tool rails | Self-hosted library or service |
| LlamaFirewall | Agent trajectory for alignment checks | Indirectly, via reasoning audit and code scan | Self-hosted, open source |
| CaMeL-style designs | Explicit data-flow and capability labels | Yes, by construction | Research; custom implementation |
The managed option buys threat intelligence and tuned models you cannot easily replicate. The self-hosted options buy control over data residency, latency and what counts as state. Many teams will run both: an open-source rail for cheap, local, deterministic checks, and a managed stateful detector for the ambiguous cases.
A Defence-in-Depth Reference Architecture
Putting the pieces together gives a layered runtime in which no single control has to be perfect. The stateful guardrail is one layer among six.

Figure 4: Defence-in-depth agent runtime: identity scoping, deterministic policy, stateful guardrail checks, sandboxed execution, egress control and audit form independent layers.
Reading top to bottom, a request enters through an AI gateway that authenticates the caller and applies rate limits. Our comparison of AI gateways for budgets, identity and routing covers that layer. The agent runtime holds session state, including history, tool-call graph and provenance labels. Every proposed action goes first to the policy engine, which applies deterministic and temporal rules, then to the stateful guardrail for risk scoring. Allowed actions run in a sandbox, as described in our comparison of agent code-execution sandboxes, with scoped credentials and an egress proxy that enforces a domain allow-list. Tool results flow back through a result scan before entering context. Every decision lands in an audit log that feeds observability and evaluation.
Failure modes by layer
Each layer fails differently, which is the point of stacking them. Identity fails through over-broad roles granted for convenience. Policy fails through gaps: the rule nobody wrote. The stateful guardrail fails through misclassification, adversarial evasion and context truncation. The sandbox fails through escape bugs or mounted secrets. Egress control fails through allowed domains that host user content, such as file-sharing and paste sites. Audit fails when logs lack the context needed to reconstruct a decision.
Design so a single failure is survivable. If the guardrail misses an injected instruction to exfiltrate data, the egress proxy should still block the unknown domain. If the egress allow-list includes a permissive domain, the guardrail’s threat-intelligence lookup or a temporal policy, such as “no outbound send after reading a secret,” should still catch it.
Capacity and operations
Treat the guardrail as a production dependency with its own service-level objective. Decide in advance what happens when it times out or errors. Failing open keeps the agent running but removes a control; failing closed protects you but turns a guardrail outage into an agent outage. A reasonable default is fail-closed for high-risk tools and fail-open-with-logging for read-only ones. Track check latency at p50 and p99, flag rate by tool, override rate by human reviewers and the share of sessions that cross your risk threshold. A sudden rise in flag rate is either an attack wave or a regression, and you need dashboards to tell which. Our LLM observability architecture post covers the telemetry pipeline.
Trade-offs, Gotchas, and What Goes Wrong
Detect-only means you own enforcement. Bedrock’s stateful checks return findings; they do not stop anything. If your integration ignores a finding, or a code path calls a tool without passing through the check, the guardrail protects nothing. Route every tool invocation through one choke point and test that no path bypasses it.
Context truncation is an evasion vector. Any system that selects “relevant” history must drop something. An attacker who knows this can push the setup turn of a payload-split attack far enough back to fall outside the window. AWS has not published how far back its context selection reaches. Pair the guardrail with deterministic temporal policies that do not forget.
The guardrail is itself an LLM-style target. Model-based detectors can be attacked with adversarial phrasing, and a detector that reads untrusted tool output is exposed to the same injection it is detecting. Do not let the guardrail’s output flow back into the agent’s context, and treat its verdict as one signal among several.
Privacy and data handling. Sending full session history to a separate service means that service sees everything the agent saw, including PII and secrets present in tool results. Check data-processing terms, regional availability and logging behaviour, especially during a preview limited to two US regions.
Preview instability. Gated previews change. Field names, behaviour, regions and pricing can all move before general availability. Keep the integration behind an adapter, and do not make a preview check the only control on anything critical.
Over-blocking erodes trust. If users see confirmations on routine actions, they either click through everything, which is approval fatigue, or abandon the agent. Both outcomes are worse than a well-tuned threshold. Start in log-only mode and measure.
No published efficacy numbers. At the time of writing, AWS has published no detection rates, false-positive rates or latency for the stateful checks. Run your own red-team evaluation, including multi-turn and indirect attacks, before relying on them.
Practical Recommendations
Start by inventorying tools by risk. Classify each tool as read-only, internal write, external send or spend, or privileged. That single label drives which checks run, which thresholds apply and whether a human confirms. Most agents have a handful of genuinely dangerous tools; gate those hardest.
Put deterministic controls first. Scoped credentials and deny-by-default policy are cheaper, faster and more predictable than any model-based check. Use the stateful guardrail for what policy cannot express: intent inferred from language and context.
Adopt stateful inspection in shadow mode. Whether you use the Bedrock preview, NeMo Guardrails or LlamaFirewall, run checks for a few weeks logging verdicts without acting on them. Compute precision on labelled samples, find the tools that generate noise, and only then switch high-risk tools to confirm or block. Gate prompt and threshold changes with evals, as described in our guide to gating agent releases with evaluations.
Engineer session state deliberately. Record provenance for every context item, serialize the tool-call graph into what the guardrail sees, summarise old turns, and keep system prompts short. That improves detection quality and controls cost at the same time.
Checklist:
- Classify every tool by risk tier and attach the tier to each call.
- Issue short-lived, task-scoped credentials to the executor.
- Enforce deny-by-default and temporal rules in a policy engine before any model-based check.
- Gate every write, send, spend or privileged call with a pre-execution stateful check.
- Scan tool results before they enter model context, and label their provenance.
- Define fail-open or fail-closed per tier, plus latency SLOs for the check.
- Start in log-only mode; measure precision before enabling blocking.
- Red-team with multi-turn, payload-split and poisoned-tool-output scenarios.
Frequently Asked Questions
What are stateful guardrails for AI agents?
Stateful guardrails for AI agents are safety checks that evaluate each new prompt, tool result or proposed tool call in the context of the system prompt and earlier session history, rather than one message at a time. This lets them detect attacks that are split across turns, built up gradually, or hidden in content returned by tools. They typically run before an action executes and return scores or findings, so the application can block the action, ask a human to confirm it, or log it for review.
Is Amazon Bedrock stateful guardrails generally available?
No. As of December 4, 2026, stateful guardrails for Amazon Bedrock Guardrails are in a gated preview, available only to allowlisted customers in US East (N. Virginia) and US West (Oregon). AWS announced the preview on November 29, 2026, with two new checks on the InvokeGuardrailChecks API: a stateful prompt-attack check and a security threat check. Pricing, latency figures and detection rates have not been published. Access is requested through your AWS account team or the preview sign-up page linked from the announcement.
What does the Bedrock Guardrails security threat check look for?
According to AWS’s announcement, the security threat check reviews user prompts and agent tool calls for three kinds of risk. It flags connections to domains and IP addresses that AWS threat intelligence marks as malicious. It flags commands that expose credentials or escalate privileges. It also flags tool calls that violate a security principle given the session so far. It is detect-only: your application decides whether to stop the call, ask the user for confirmation, or simply log the finding.
How is a stateful guardrail different from a policy engine like Cedar?
A stateful guardrail is probabilistic. It reads natural language and context and estimates whether something looks like an attack or a security violation. A policy engine such as Cedar, or Cedar-based Dogwood temporal policies, is deterministic. It evaluates explicit rules about who may do what, in which order and within which limits. Policy reliably blocks what you anticipated and wrote down, while the guardrail catches disguised or novel attacks within what policy allows. Production agents should use both, with identity scoping underneath.
Do stateful guardrails stop multi-turn prompt injection completely?
No. They raise the bar by seeing patterns that per-message filters miss, but they remain model-based detectors with false negatives. Attackers can try adversarial phrasing or push setup turns outside the context the guardrail examines. AWS itself does not promise that a request with no finding is safe. Treat the guardrail as one layer, combined with least-privilege credentials, deterministic policies, sandboxed execution, egress allow-lists and human approval for high-impact actions, so that a single missed detection does not become a breach.
Are there open-source alternatives to Bedrock stateful guardrails?
Yes, with different scopes. NVIDIA NeMo Guardrails 0.25.0 provides tool-call hooks and per-tool rails that check arguments and results with regular expressions, CEL expressions or an LLM judge. Meta’s LlamaFirewall combines PromptGuard 2 for jailbreak detection, an AlignmentCheck auditor that inspects agent reasoning, and CodeShield for generated code. Research systems such as CaMeL enforce data-flow and capability policies by construction. None ships AWS’s threat intelligence, but all can be self-hosted for data-residency or latency reasons.
Further Reading
- Agentic AI security and the prompt-injection kill-chain: the broader threat model this control fits into.
- MCP server security: tool poisoning, confused deputy and OAuth resource indicators: how tools become injection channels.
- AWS Greenlight explained: automated-reasoning policy enforcement for AI agents: the deterministic counterpart to stateful guardrails.
- AWS Continuum explained: scanning MCP servers, agent skills and agent inventory: knowing which agents and tools you have before you guard them.
- AWS What’s New: Amazon Bedrock Guardrails announces stateful guardrails in gated preview: the primary announcement.
- OWASP Top 10 for Agentic Applications: the agent-specific risk taxonomy used in the mapping above.
By Riju — about
