A 10-line drop-in Python/TypeScript wrapper that detects repeating tool retry loops, enforces hard session spending ceilings, and triggers safe fallbacks in real-time.
See Loop-Guard in action right in your browser. Choose a broken agent scenario and watch the circuit breaker halt execution.
Drop it into your existing OpenAI, Anthropic, or LangGraph agent in 3 simple steps.
Available for Python and TypeScript with zero heavy dependencies:
# Python
pip install ./runlog_loopguard-0.1.0-py3-none-any.whl
# TypeScript / Node.js
npm install ./runlog-loopguard-0.1.0.tgz
Wrap your existing OpenAI client instance:
from openai import OpenAI
from loopguard import CircuitBreaker, TripPolicy, wrap_openai
# Set 3-retry threshold and $2.00 hard budget ceiling
guard = CircuitBreaker(
policy=TripPolicy(
max_consecutive_retries=3,
max_cost_usd=2.00,
fallback_mode="synthetic_response"
)
)
client = wrap_openai(OpenAI(), guard)
Get instant notifications if an agent is halted:
from loopguard import AlertDispatcher
alerts = AlertDispatcher(
slack_webhook_url="https://hooks.slack.com/...",
telegram_bot_token="123456:ABC...",
telegram_chat_id="-100123456789"
)
guard.on_trip_callback = lambda cb, details: alerts.notify_trip(cb.to_dict(), details)
Versioned Python and TypeScript packages with source and checksums. Hosted telemetry and platform billing are not available for purchase yet.
Retry/cycle detection, local session budget checks, and optional webhook alert integrations run inside your application. Configure and test thresholds for your workload. Budget checks depend on observed token usage and are not a guarantee against all upstream charges.