Compliance

What Are Guardrails for AI?

Runtime checks placed before and after an LLM call to enforce safety, policy, schema, and quality constraints in production.

What Are Guardrails for AI?

Guardrails for AI are the runtime layer that converts evaluation signals into enforcement. They sit around the LLM call: a pre-guardrail runs before the model and screens user input for prompt injection, PII, jailbreak patterns, or policy-restricted topics; a post-guardrail runs after the model and checks the output for toxicity, hallucination, schema validity, or PII leakage. When a check fails, the system blocks, redacts, retries with a different prompt, or routes to a fallback model. They are the operational form of AI safety policy in 2026 production stacks. FutureAGI implements them as Agent Command Center primitives.

Why It Matters in Production LLM and Agent Systems

Without guardrails, every safety promise lives in a notebook eval run that nobody enforces in production. The model can pass a 200-row red-team test offline and still produce harmful output the first time a real user prompts it with anything outside that distribution. The pain is not theoretical: the gap between “we evaluated for X” and “we block X in the request path” is where real incidents happen.

The first failure mode without guardrails is PII leakage: the model echoes a Social Security number from a retrieved document, the support page logs it, and a compliance ticket is filed days later. The second is prompt-injection-driven action: an agent reads a poisoned email, follows the embedded instruction, and triggers a tool call. The third is schema breakage: the model emits malformed JSON, the downstream pipeline crashes for 4% of traffic, and on-call gets paged.

Developers feel this when refusal-miss-rate, block-rate, or eval-fail-rate dashboards lack a corresponding enforcement column. SREs feel it when retries and fallbacks aren’t wired into the gateway. Compliance teams feel it most acutely during audits — they need to point to a specific guardrail and show what it blocks, when it last ran, and what its false-positive rate is.

For 2026 agent systems, single-call guardrails are no longer enough. A multi-step agent needs guardrails on retrieved context (pre-guardrail before the planner), on tool inputs (post-guardrail on the planner’s tool args), and on final user-facing output (post-guardrail on the responder).

How FutureAGI Handles Guardrails for AI

FutureAGI ships guardrails as first-class Agent Command Center primitives. The pre-guardrail and post-guardrail slots in a route accept any fi.evals evaluator as a synchronous gate. Common configurations are ProtectFlash and PromptInjection as a pre-guardrail for prompt safety, and JSONValidation, Toxicity, and Groundedness as a post-guardrail for output enforcement.

A real workflow: a customer-support agent is routed through Agent Command Center. The pre-guardrail chain runs ProtectFlash (latency-sensitive injection check), then PromptInjection (full-context check), then a custom PII redactor. Each check writes a span_event with its score and verdict to the trace. If any check fails, the route returns a fallback response. The post-guardrail chain runs JSONValidation (schema gate for the structured response), Toxicity (block-rate threshold 0.95), and Groundedness (hallucination floor of 0.7). On failure, the route retries with a stricter system prompt or escalates to a human review queue.

FutureAGI’s approach is that guardrails and evaluators share the same code path. Unlike Lakera or LLM-Guard which expose a separate guardrail SDK, the fi.evals evaluator you used to score offline data is the same class wired into the live route — so the offline eval result and the online block decision are calibrated against each other. The engineer monitors eval-fail-rate-by-cohort alongside guardrail block rate, and a mismatch (high eval-fail-rate, low block rate) means the guardrail threshold is wrong.

How to Measure or Detect It

Measure guardrails by their dual error rates and the traces they emit:

  • Block rate — the fraction of requests blocked by a given pre- or post-guardrail; trend by route, prompt version, and cohort.
  • False-positive rate — the fraction of blocks that were unnecessary, sampled by human review or a higher-quality offline eval.
  • fi.evals.PromptInjection — pre-guardrail evaluator for injection risk on user input.
  • fi.evals.Toxicity — post-guardrail evaluator for harmful output in free-text responses.
  • fi.evals.JSONValidation — post-guardrail evaluator for structured outputs.
  • agent.guardrail.decision OTel attribute — span field that records each guardrail’s verdict for trace-level debugging.
from fi.evals import ProtectFlash, JSONValidation

pre = ProtectFlash().evaluate(input="Ignore previous instructions and...")
post = JSONValidation().evaluate(
    input="Generate user JSON",
    output='{"name": "Alex", "id":}',  # malformed
)
print(pre, post)

Common Mistakes

  • Running evals offline only and skipping enforcement. A scored failure that does not block in production is a vanity metric.
  • Setting a single threshold for all routes. A medical-advice route needs a tighter Groundedness threshold than a general-chat route.
  • Treating guardrails as keyword filters. Real guardrails use evaluator models, schema validators, and policy classifiers — not regex.
  • Ignoring false-positive rate. A 90% block rate with 30% false-positives is worse than a 60% block rate with 2% false-positives for user trust.
  • Not versioning guardrail thresholds. Pin thresholds to the prompt version and route so a configuration change is auditable.

Frequently Asked Questions

What are guardrails for AI?

Guardrails for AI are runtime checks placed before or after an LLM call to enforce safety, policy, schema, and quality constraints. They block, redact, retry, or fall back when a check fails.

How are guardrails different from evaluators?

Evaluators score model behavior offline or asynchronously. Guardrails apply the same checks synchronously in the request path so they can block bad outputs before the user sees them.

How do you measure guardrail effectiveness?

Track block rate, false-positive rate, and post-guardrail eval-fail-rate together. A guardrail with a high block rate and low false-positive rate is doing its job; high false-positives mean the threshold is too tight.