cd /news/ai-agents/agentguard-zero-dependency-loop-and-… · home › topics › ai-agents › article
[ARTICLE · art-179067] src=github.com ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

AgentGuard – Zero-dependency loop and spend guardrails for AI agents

A developer publishing as nemor1-bit released AgentGuard, a zero-dependency Python library that adds runtime guardrails to AI agents, installable via pip from its GitHub repository. AgentGuard enforces per-action spend caps (max_spend, e.g. $50), session totals (max_total_spend, e.g. $500), consecutive tool-loop limits (max_consecutive_repeats=4), a 300-second idempotency window against duplicate retries, human-approval gates for actions such as send_email and charge_card, and verify-after-act checks via verify_fn. The project also offers a $750 paid setup service and an enterprise waitlist for Redis-backed idempotency, SOC2 compliance logs and RBAC for 10,000+ agents.

key takeaway

AgentGuard wraps agent tools with a @guard.protect decorator that enforces per-action and per-session spend caps, kills loops after max_consecutive_repeats identical tool calls, blocks duplicate (action, args, kwargs) retries within a 300-second idempotency window, and pauses irreversible actions fo

read2 min views3 publishedDec 1, 2026
AgentGuard – Zero-dependency loop and spend guardrails for AI agents
Image: Michielbdejong (auto-discovered)

The zero-dependency runtime seatbelt, loop killer, and human-approval gate for AI Agents.

https://nemor1-bit.github.io/agentguard/

AgentGuard protects production AI agents from the quiet failures that dollar caps alone miss—stopping consecutive tool loops, duplicate retries on timeouts, unverified side effects, and unapproved irreversible actions.

pip install git+https://github.com/nemor1-bit/agentguard.git
python
from agentguard import AgentGuard

guard = AgentGuard(
    max_spend=50,                       # Max \$50 per action
    max_total_spend=500,                # Max \$500 across the session
    max_consecutive_repeats=4,          # Kill stuck loops repeating the same tool
    idempotency_window=300,             # Block duplicate retries within 5 minutes
    require_approval_for=["send_email", "charge_card"],
    approval_callback=lambda action, cost: input(f"Approve {action}? (y/n): ") == "y",
    webhook_url="https://slack.com"
)

@guard.protect(
    cost_fn=lambda user_id, amount: amount,
    verify_fn=lambda result, user_id, amount: result.get("paid") is True
)
def charge_card(user_id, amount):
    return {"paid": True, "tx_id": "tx_991"}

charge_card("usr_42", 25)  # s for human approval -> executes -> verifies effect
charge_card("usr_42", 25)  # 🛑 Blocked automatically (duplicate action within 300s)

Aggregate Dollar-Velocity Caps (max_spend_per_minute): Stops rapid spend bleed (e.g., ten $2 calls in 60 seconds) even when every single action is undermax_spend . #

Strict Tool Allowlisting (allowed_tools): Eliminates keyword whack-a-mole by blocking any tool not explicitly allowlisted. #

Dry-Run / Shadow Preview Mode (dry_run=True): Simulates full agent workflows through every policy check and outputs a projected spend receipt (get_dry_run_summary() ) before committing real side effects. #

Consecutive Tool-Loop Detection (max_consecutive_repeats): Halts runs when an agent calls the same tool repeatedly—even if arguments change slightly or calls are spaced out. #

Human-in-the-Loop Approval Gate (require_approval_for): s execution on irreversible actions ( send ,pay ,delete ) until a human approves via callback or webhook. #

Duplicate-Action Prevention (Idempotency): Automatically hashes(action, args, kwargs) to block double-charges and duplicate emails after API timeouts. #

Verify-After-Act (verify_fn): Runs a lightweight post-execution check to catch silent failures when an agent reports success without the real-world effect occurring. #

Two-Phase Variable Cost Accounting: Supports dynamic pre-flightcost_fn estimation plusrecord_actual_cost() post-call reconciliation. #

OpenAI Tool Validation & Alerts: Nativeguard_openai_tool_call() , keyword kill-switches, timestamped audit logs, and Slack/Discord alerts. #

Need distributed Redis idempotency, SOC2 compliance logs, and RBAC for 10,000+ agents? Join the Enterprise Waitlist . #

Need hands-on help wiring AgentGuard into your production OpenAI or LangChain agents? Book a Priority Setup & Custom Guardrails session ($750) .

── more in #ai-agents 4 stories · sorted by recency
── more on @agentguard 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/agentguard-zero-depe…] indexed:0 read:2min 2026-12-01 · —