Guardrails
Safety Nets for Production AI
Define hard limits, soft alerts, rate caps, and statistical drift detectors. When something goes wrong, Winnow kills the offending arm automatically -- before degraded quality reaches your users.
import winnow
# Configure guardrails for an experiment
winnow.set_guardrails(
experiment="gpt4o-vs-claude-summarization",
rules=[
winnow.Guardrail(
type="HARD",
metric="error_rate",
threshold=0.05,
action="kill_arm", # immediately stop the arm
),
winnow.Guardrail(
type="SOFT",
metric="latency_p95",
threshold=2000, # ms
action="alert",
channel="slack:#ml-alerts",
),
winnow.Guardrail(
type="STAT",
method="cusum",
metric="quality_score",
sensitivity=3.0, # sigma
action="pause_and_review",
),
winnow.Guardrail(
type="LIMIT",
metric="cost_per_query",
threshold=0.05, # USD
window="1h",
action="throttle",
),
],
)Defense in Depth for AI
Layer multiple guardrail types to catch issues at every level -- from hard crashes to subtle statistical drift.
4 Guardrail Types
HARD guardrails kill immediately on breach. SOFT guardrails alert but allow traffic. LIMIT guardrails cap spend or throughput. STAT guardrails use statistical tests to detect drift.
Auto-Kill on Breach
When a HARD guardrail fires, the experiment arm is stopped instantly and traffic is redirected to the control. No human in the loop required for safety-critical metrics.
CUSUM Drift Detection
Cumulative Sum (CUSUM) change detection identifies subtle, sustained shifts in quality metrics that would be invisible to simple threshold checks.
Guardrail Presets
Choose from 3 preset levels -- Permissive, Moderate, and Strict -- for instant setup. Customize individual rules as your needs evolve.
Health Dashboard
A live view of every guardrail across all experiments. See current metric values, distance to thresholds, recent breaches, and historical trends at a glance.
Guardrails that understand AI
Simple threshold alerts miss the nuance of AI systems. A model might degrade slowly over days, or spike on a specific user segment. Winnow guardrails combine real-time thresholds with statistical process control to catch both sudden failures and gradual drift.
Auto-rollback when guardrails fire
Bind a guardrail to a gate, experiment, or judge. The monitor loop watches the rolling window. If it breaches, the last known good config is restored.
Last known good
Every config write captures a content-addressable snapshot. The most recent snapshot that survived its dwell + green window becomes the LKG. Auto-revert never restores a config that itself was breaching.
Sequential CI
Single-threshold and ratio guardrails support Howard-2021 mSPRT corrections. The monitor only fires when the rolling CI excludes the threshold, so a noisy window can't trigger a spurious rollback.
Promotion gate
A new config does not become LKG until it has been live for the dwell, stayed green for the green window, and seen enough samples. Configurable per binding.
Safety rules in the loop
- No last-known-good yet? The loop downgrades to an alert and pages the on-call instead of failing open.
- Snapshot schema has drifted? Revert is refused, on-call is alerted, and no rollback event is written.
- Control arms are immune to snapshot apply, so a stale snapshot can never zero out the holdout.
- Cooldown after every revert. An admin can resume early via the API, SDK, or MCP if a breach is a known false positive.
Ship fast, stay safe
Add guardrails to any experiment in seconds. Presets get you started immediately. Free on all plans.
Start Free