$pip install agentcorrect
Stop your AI agent from spending $1000 by accident
A simple rate limiter that actually works. Prevents infinite loops, duplicate API calls, and runaway costs. We've saved ~50 users from expensive mistakes.
What it actually does
Sets hard limits on iterations, API calls, and costs. That's it. Dead simple.
Real example from one of our users
Without rate limiting
# Agent stuck in refinement loop
for i in range(1000):
response = openai.complete(
prompt="Refine this...",
tokens=10000
)
# Ran 1000 times
# Cost: $1,200 in 3 minutes
# OpenAI bill shock
for i in range(1000):
response = openai.complete(
prompt="Refine this...",
tokens=10000
)
# Ran 1000 times
# Cost: $1,200 in 3 minutes
# OpenAI bill shock
With AgentCorrect
# Same code, now protected
limiter = RateLimiter(max_iterations=10)
agent = limiter.wrap(agent)
# Stops at 10 iterations
# Cost: $3.00
# Saved: $1,197
# That's literally all it does
limiter = RateLimiter(max_iterations=10)
agent = limiter.wrap(agent)
# Stops at 10 iterations
# Cost: $3.00
# Saved: $1,197
# That's literally all it does
How it works
Count things. Stop when limit reached.
1
Set limits
max_iterations=50, max_cost_per_hour=$10
2
Wrap your agent
agent = limiter.wrap(your_agent)
3
It stops when limits hit
Throws exception. Agent stops. Money saved.
Problems it prevents
Real incidents from our users
Infinite refinement loops
Agent kept refining same document 1000 times
Stopped at: 10 iterations
$1,200 OpenAI bill
Bug caused agent to call GPT-4 repeatedly
Stopped at: $10/hour
Duplicate emails
Agent sent same email 47 times to customer
Stopped at: 3 duplicates
API rate limit bans
Agent hit OpenAI rate limits, got banned
Stopped at: 50 calls/minute
Works with anything
Literally wraps any Python object
from agentcorrect import RateLimiter
limiter = RateLimiter(
max_iterations=50,
max_cost_per_hour=10.0,
max_identical_actions=3
)
# Works with anything
agent = limiter.wrap(your_agent)
# That's it. 200 lines of code total.
limiter = RateLimiter(
max_iterations=50,
max_cost_per_hour=10.0,
max_identical_actions=3
)
# Works with anything
agent = limiter.wrap(your_agent)
# That's it. 200 lines of code total.