Fail-Open vs Fail-Closed AI Guardrails
Fail-open vs fail-closed guardrail behavior — trade-offs for chat, financial actions, customer-facing output, and destructive agent tools.
When a guardrail service times out, returns an error, or cannot reach your application, what happens next? Fail-open lets the request continue without the check. Fail-closed blocks or routes the request to a safe fallback until the guardrail layer is healthy again.
Neither choice is universally correct. The right default depends on what fails if the check is skipped — a blocked support reply, a missed injection in a financial workflow, or a degraded chat experience during an outage.
Definitions
| Behavior | On guardrail failure | User experience | Security posture |
|---|---|---|---|
| Fail-open | LLM call proceeds | Service stays available | Higher risk during outages |
| Fail-closed | LLM call blocked or queued | Errors or fallback messages | Stronger protection; availability cost |
| Fail-degraded | Reduced checks or cached allowlist | Partial functionality | Hybrid; requires explicit design |
Guardrails include prompt injection screening, PII/secrets detection, output moderation, and agent action policies. Each can have different fail behavior. See What Are AI Guardrails? for the full scope.
Why this decision matters
Guardrail APIs are network dependencies. They add latency (latency guide), can rate-limit under load, and occasionally fail for reasons outside your control. Your application must define behavior before production — not during an incident.
Consider two scenarios:
- Internal summarization tool — no external actions, no PII, plain-text output. Brief fail-open with alerting may be acceptable.
- Customer-facing support bot with tool access — retrieved documents, email send capability, regulated data. Fail-closed on injection and secrets checks is usually appropriate.
The mistake teams make is applying one global default across every check and every product surface.
Fail-open: when it fits
Fail-open prioritizes availability. Use it when:
- The feature is low-risk and internal-only
- Blocking would cause disproportionate business harm (e.g., read-only FAQ bot with no tools)
- You have compensating controls (no sensitive retrieval, no side effects, output encoding only)
- You can detect and alert on guardrail failures quickly
Risks of fail-open:
- Outages become silent security gaps — users get unscreened LLM responses
- Attackers may probe during degraded periods if failure modes are observable
- Compliance reviewers often challenge undocumented bypass paths
If you fail-open, document it in your threat model, log every skipped check with request_id and reason, and page on sustained guardrail unavailability.
Fail-closed: when it fits
Fail-closed prioritizes safety. Use it when:
- User input or retrieved content is untrusted
- Model output is rendered as HTML or triggers tools
- Secrets or PII in prompts would reach a third-party provider
- Regulatory or contractual obligations require screening
Risks of fail-closed:
- Guardrail outages become product outages
- Support volume spikes when users see generic error messages
- False sense of security if only some checks fail-closed while others fail-open
Pair fail-closed with pre-approved fallback copy that does not echo user input, and monitor error rates separately from moderation blocks.
Per-check policies (recommended)
Most production systems should not use a single global setting. Map fail behavior to check type and surface:
| Check | Typical fail behavior | Rationale |
|---|---|---|
| Prompt injection (user input) | Fail-closed | Direct attack surface |
| Prompt injection (RAG chunks) | Fail-closed or drop chunk | Indirect injection path |
| PII/secrets in user input | Fail-closed | Credential exposure is irreversible |
| Output moderation | Fail-closed for unsafe; consider review queue on API error | Balance UX vs markup safety |
| Agent destructive tools | Fail-closed | Irreversible actions |
| Low-risk internal autocomplete | Fail-open with alert | Availability over marginal risk |
Unified Guard returns a consolidated decision (block, review, allow) from multiple checks. Your application still defines what happens when the API call itself fails — that is separate from per-check verdicts.
Implementation patterns
Explicit policy configuration
Store fail behavior in version-controlled config, not scattered if branches:
const GUARDRAIL_FAIL_POLICY = {
prompt_injection: "closed",
pii_secrets: "closed",
output_safety: "closed",
timeout_ms: 3000
} as const;
Timeout and circuit breaker
Set timeouts below your user-facing SLA. After repeated failures, a circuit breaker can:
- Fail-closed for high-risk paths
- Fail-open for explicitly allowlisted low-risk paths (rare; document heavily)
See How Guardrails Affect AI Application Latency for timeout budgeting.
Unified Guard with fail-closed wrapper
POST /api/v1/guard
Authorization: Bearer idapi_test_your_key_here
Content-Type: application/json
{
"text": "User message before LLM call",
"checks": ["prompt_injection", "pii_secrets"]
}
On HTTP success, route by decision. On timeout or 5xx, apply your documented fail policy — do not implicitly proceed.
Graceful user messaging
Fail-closed should not leak internals:
- ❌ "Guardrail API returned 503"
- ✅ "We're unable to process this request right now. Please try again shortly."
Log request_id, check name, and error class server-side for debugging.
Comparison by product type
| Product type | Suggested default | Notes |
|---|---|---|
| Public chatbot | Fail-closed on input injection + output safety | Add review for suspicious (block vs review) |
| RAG document Q&A | Fail-closed on chunk screening | See RAG Security |
| AI SaaS multi-tenant | Fail-closed on cross-tenant boundaries + secrets | Per-tenant policy overrides |
| Internal codegen assistant | Mixed — closed on secrets, open on injection with logging | Depends on repo access |
| Agent with payments/delete | Fail-closed on all pre-tool checks | Agent permissions |
Testing fail behavior
Include failure injection in your test plan (evaluate guardrails):
- Simulate 503/timeout from guardrail API — assert documented behavior
- Verify fallback messages never echo blocked input
- Confirm alerts fire when checks are skipped (fail-open paths)
- Load test: circuit breaker does not silently widen attack window
Relationship to false positives
Fail-open is sometimes chosen to reduce friction from false positives. That trades one problem for another — availability during detector uncertainty vs security during outages. Better approaches: review verdicts, tuned thresholds, and surface-specific policies (false positives guide).
Summary
- Fail-open keeps the product running when guardrails are unavailable; accept higher risk and require strong monitoring.
- Fail-closed protects users and data during outages; accept availability cost and invest in fallback UX.
- Per-check policies match real threat models better than a single global default.
- Document, test, and alert on every fail path — undocumented fail-open is a latent vulnerability.
Layer guardrails in depth (LLM defense in depth) and define fail behavior as explicitly as you define allow/block verdicts. Unified Guard orchestrates multiple checks in one request; your application owns what happens when orchestration itself fails.
Frequently asked questions
What is fail-open vs fail-closed for AI guardrails?
Fail-open allows the LLM request to proceed when a guardrail API errors or times out. Fail-closed blocks or routes to a safe fallback until checks succeed. The right choice depends on threat model, data sensitivity, and availability requirements.
Should all guardrail checks use the same fail behavior?
Usually not. Many teams fail-closed on secrets and injection checks, while using stricter review routing for output moderation. Document per-check policies instead of one global default.
How does fail behavior relate to Unified Guard?
Unified Guard returns allow, review, or block decisions when the API call succeeds. Your application must separately define what happens when POST /api/v1/guard itself fails — that is independent of per-check verdicts.
How do I test guardrail fail behavior?
Simulate timeouts and 5xx responses in staging. Assert user-facing fallbacks do not echo input, alerts fire on skipped checks, and documented fail-closed paths actually block provider calls.
Does fail-open reduce false positives?
Fail-open addresses availability during outages, not detector false positives. For borderline detections, use review verdicts and tuned routing rather than bypassing checks when the API is healthy.
Related reading
- How to Handle False Positives in AI Guardrails
Reduce guardrail false positives with review states, thresholds, detector-specific tuning, and production measurement — …
- How to Evaluate an AI Guardrail System
Evaluate guardrail systems with representative test sets, false positive/negative analysis, latency, failure behavior, p…
- How to Build Defense in Depth for LLM Applications
Defense in depth for LLM apps — authentication, input validation, injection detection, PII protection, output moderation…
- How Guardrails Affect AI Application Latency
Guardrails add latency — sequential vs parallel checks, deterministic rules, network overhead, and fail behavior. Archit…