Skip to content

How much latency does a guardrail add to an AI agent? We measured 109 agent repositories

A guard check adds 57.4 ms at the median on traffic from 109 real agent repositories. What moves it, and how it compares with other guards.

The AgentFox team7 min read

The AgentFox latency benchmark page: median latency per check with the ML classifier, per tool call, and without the model.

The short answer

Every team we talk to asks the same question before they put a guardrail in front of an agent: how much slower will it get? So we measured it on agents people actually built: 41,520 guard calls replayed from 109 open agent repositories and a few private ones.

With the default detectors, which include an ML prompt-injection classifier, a check adds 57.4 ms at the median and 302 ms at p95. With only the deterministic checks, it adds 2.3 ms. The tail is long text: messages under 200 characters take 54.5 ms at the median, and between 200 and 600 characters 188 ms, because the classifier has more to read. The rest of this post is where those numbers come from, what moves them, and how they compare with other guards.

How we measured it

We pointed agentfox init at each repository. It maps the agents the code defines, the tools each one is handed and which agent hands work to which, across LangGraph, CrewAI, AutoGen, the OpenAI Agents SDK, Google ADK, Agno, Pydantic AI, TypeScript frameworks and plain code. From each map we replayed three kinds of traffic through the same guard endpoints an SDK calls:

  • a single turn: user message, tool call, tool result, reply;
  • a five-turn session, benign questions first and attacks after;
  • a multi-agent handoff: root agent, sub-agent, its tool, and back.

The messages are attacks and benign controls written against each repository's real agents and tools. Everything ran on an Apple M1 Pro, CPU only, one gateway worker, Python 3.12 as in our production image. We report the gateway's own time per check, so the agent's model and the network are not in it.

What each layer costs

AgentFox runs detectors in layers you choose. Per check, at the median and p95:

  • Deterministic (patterns, PII, secrets, schema, invisible Unicode, insecure code): 2.3 / 6.4 ms.
  • Default (plus the ML prompt-injection classifier): 57.4 / 302 ms.
  • Extended (plus similarity search against known attacks): 9.9 / 276 ms, with the score cache on.
  • With LLM judges, in the default mode where a judge waits only when a rule relies on it: 76.5 / 1,009 ms. Replies pay a commitment check, about 0.88 s.

A whole single-agent turn, four guard calls, adds 179 ms at the median with the default layer. The full tables, per step and per scenario, are on the benchmark page.

What moves latency, and what does not

Text length moves it. Checking a tool call's arguments costs about 3.1 ms, because there is little prose to read. A long tool result costs several times a short question, because the classifier reads text in 256-token windows.

Conversation length does not. Per-check latency was flat from the first turn of a session to the fifth: a guard that re-read the whole history on every turn would get slower as the conversation went on, and this one does not.

Framework and shape barely matter. Single-agent, independent-agent and multi-agent repositories landed within a few milliseconds of each other per check, and so did the frameworks. The guard does no framework-specific work on a check.

Against other guards, on one machine

Published latency figures are hard to compare: few vendors publish one, fewer say on what hardware, with how long a message or whether the network is included. So we ran the others ourselves, on the same 880 messages, the same machine and the same Python.

We ran AgentFox at every level. On short messages, its deterministic checks took 7.4 ms at the median and its default checks took 63.1 ms. LLM Guard's prompt-injection scanner took 56.1 ms, Prompt Guard 2 86M 54.4 ms, Prompt Guard 2 22M 25.5 ms, and the Guardrails AI jailbreak validator 99.4 ms. LLM Guard's nine default scanners together took 249 ms, and OpenAI's hosted moderation API 387 ms, about 260 ms of it the network.

The base-size models are the same speed: AgentFox's classifier, the one inside LLM Guard's scanner and Prompt Guard 2 86M all take about 50 ms. The difference is what surrounds them. AgentFox answers over HTTP and runs its PII, secrets and other checks on the same call; LLM Guard's scanner detects injection and nothing else. The 22M model is faster because it is a quarter of the size.

On long messages AgentFox does more work on purpose. It reads the first 4,000 characters in overlapping windows, where the others stop at 512 tokens, so an injection buried deep in a long document is read at all. Long text gets a larger check budget, 1,000 ms against 300, so the classifier finishes reading it: a long-message p95 of 412 ms on a laptop CPU.

When an LLM judge is in the loop

An LLM judge is a different order of cost. NVIDIA NeMo Guardrails' self-check rail, one gpt-4.1-mini call, took 758 ms at the median on the same messages; AgentFox with its judges on every check took 865 ms. Most of that gap is the answer: our judge scores three things (an instruction override, data exfiltration, personal data) where NeMo's asks one yes-or-no question.

In practice the judge rarely sits on the request path. By default it only runs inline when an enforcing rule relies on its answer; otherwise it runs after the response and its verdict is still recorded against the same trace.

Keeping it fast in production

  • Run the gateway beside the agent. Network is the largest number in any hosted guard's latency. Self-hosted, a check never leaves the machine.
  • Choose the layer per agent. Deterministic checks cost single milliseconds; turn the classifier on where untrusted text reaches the agent.
  • Keep the score cache on. System prompts, tool descriptions and retrieved chunks repeat, and a repeated text is scored once.
  • Keep judges off the hot path unless a rule needs their answer before the action.

Everything above, every recorded call and the scripts to rerun it are in benchmarks/latency.

Frequently asked questions

How much latency does an AI agent guardrail add?

With AgentFox's default detectors, 57.4 ms at the median and 302 ms at p95 per check on a laptop CPU, measured on traffic from 109 real agent repositories; longer text drives the tail. Deterministic checks alone add 2.3 ms. An LLM judge in the loop adds about a second, mostly the model's own response time.

Is AgentFox slower than LLM Guard or Prompt Guard?

On short messages on the same machine, AgentFox's default checks took 63.1 ms at the median against 56.1 ms for LLM Guard's prompt-injection scanner and 54.4 ms for Prompt Guard 2 86M. The models are the same size; AgentFox adds an HTTP round trip and its PII, secrets and other checks. Prompt Guard 2 22M is faster, at 25.5 ms. AgentFox's deterministic checks alone took 7.4 ms.

Does guardrail latency grow over a long conversation?

No. Per-check latency was flat from the first turn of a session to the fifth. What moves it is the length of the text being checked.

Where can I see the raw data?

Every recorded call, the per-repository results, the scripts and the head-to-head harness are in benchmarks/latency in the AgentFox repository, and the latency benchmark page on this site summarises them.

Try AgentFox on your own agent

One command finds your agents. It starts in watch mode, so nothing is blocked until you say so.

uvx agentfox scan