Agent Guardrails
Overview
Agents go rogue. They overspend. They call tools they shouldn’t. They run at 3am doing things nobody asked for.
Agent Guardrails is fraud prevention for AI agents — behavioral rules, anomaly detection, and automatic intervention.
Think Stripe Radar, but for agents instead of credit cards.
Behavioral Rules
Define what your agent can and can’t do:
from fiftyc import AgentAuthimport os
agent = AgentAuth(api_key=os.getenv("FIFTYC_API_KEY"))
# Rate limitingagent.add_rule("max_calls_per_minute", 10)
# Time restrictionsagent.add_rule("block_tools_after_hours", True)agent.add_rule("active_hours", {"start": "08:00", "end": "22:00", "tz": "UTC"})
# Pattern blockingagent.guard( blocked_patterns=["exec(", "rm -rf", "DROP TABLE"], max_spend_per_hour=50)Anomaly Detection
Automatic alerts when agent behavior deviates from normal:
| Signal | Trigger | Action |
|---|---|---|
| Spend spike | 4x daily average in 1 hour | Alert human |
| Error surge | Error rate jumps from 5% to 40% | Pause agent |
| Off-hours activity | Calls outside configured hours | Block + alert |
| Tool pattern change | Agent suddenly using tools it never used | Flag for review |
| Rapid-fire calls | >100 calls/minute | Rate limit + alert |
# Configure anomaly detectionagent.anomaly_detection( spend_spike_threshold=4.0, # 4x normal = alert error_rate_threshold=0.4, # 40% errors = pause alert_channel="webhook", # or "email", "slack" alert_url="https://your-app.com/agent-alerts")Auto-Intervention
When guardrails trigger, the system can act automatically:
agent.configure_interventions( on_spend_spike="pause_and_alert", # Pause agent, notify human on_error_surge="pause_and_alert", # Pause agent, notify human on_blocked_pattern="kill", # Immediate revoke on_rate_limit="throttle" # Slow down, don't kill)Intervention Levels
| Level | What Happens | When |
|---|---|---|
| Throttle | Slow agent to 1 call/min | Rate limit exceeded |
| Pause | Stop agent, wait for human resume | Spend spike or error surge |
| Kill | Revoke all permissions permanently | Blocked pattern detected |
| Alert | Notify human, agent continues | Off-hours or unusual tool usage |
Why This Matters
The #1 blocker for enterprise agent adoption is trust:
“What if my agent goes rogue?” “How do I prove to my CISO that agents are controlled?” “What if an agent drains my budget overnight?”
Guardrails make agents enterprise-safe:
- Every rule is server-side enforced (can’t be bypassed by the agent)
- Every intervention is logged in the audit trail
- Humans stay in control without micromanaging every call
Integration with Agent Auth
Guardrails are part of the Agent Auth SDK. They work automatically with Agent Wallets — no separate setup needed.
# Full setup: auth + wallet + guardrails in oneagent = AgentAuth(api_key=os.getenv("FIFTYC_API_KEY"))
agent.configure( auto_approve_below=10, require_approval_above=50, kill_after=500)
agent.add_rule("max_calls_per_minute", 10)agent.add_rule("block_tools_after_hours", True)
agent.anomaly_detection( spend_spike_threshold=4.0, alert_channel="webhook", alert_url="https://your-app.com/alerts")
# Agent runs with full protection@agent.authorize(credit_limit=100)def my_agent_task(): return agent.call("genius", problem="Optimize logistics")