cd /news/ai-agents/agents-that-don-t-quit-rate-limits-m… · home › topics › ai-agents › article
[ARTICLE · art-178064] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Agents that don't quit: rate limits, memory, loops, and broken files

A developer released Unstuck, a free, open-source, stdlib-only Python library that addresses four common infrastructure failures in agent loops: rate limits, context-window overflow, repeated-action loops, and unrecoverable file edits. The library provides four classes — PoliteWaiter, SmartMemory, LoopAlarm, and CheckpointManager — totaling under 300 lines, with no API keys, internet access, or package installs required. The developer says the top cause of failed agent runs is infrastructure, not prompting, and cites agents burning through $2 of API credits repeating the same broken command.

key takeaway

Unstuck's four stdlib-only classes — PoliteWaiter (retry-after plus exponential backoff, capped at five attempts), SmartMemory (summarize the oldest messages every six exchanges), LoopAlarm (halt after three identical actions), and CheckpointManager (snapshot files before each mutation) — give agent

by read3 min views7 publishedNov 29, 2026

I run eleven AI apps. Most of them are agents — they read input, call a model, act on the result, repeat. And the #1 reason an agent run dies isn't bad prompts. It's one of four boring infrastructure failures:

I built Unstuck to fix all four. It's stdlib-only Python, free, open-source, with green CI. Here's why each pain exists, and how to handle it without a framework.

Most agent loops look like this:

while True:
    response = llm.call(messages)
    result = tool.execute(response.tool_call)
    messages.append(result)

When the model API returns 429, the naive agent crashes. Retry logic is usually an afterthought, bolted on with time.sleep(60) — which blocks everything, or worse, no retry at all.

Unstuck's waiter treats rate limits as expected, not exceptional:

from src.waiter import PoliteWaiter

waiter = PoliteWaiter(max_retries=5, base_delay=2.0)

for attempt in waiter.retry():
    try:
        response = llm.call(messages)
        break
    except RateLimitError as e:
        waiter.sleep(e.retry_after or waiter.next_delay())

Key details: it reads retry-after from the response when the API provides it, uses exponential backoff otherwise, and never retries forever. Five attempts, then it hands back control. A rate limit is a slowdown, not a crash.

Agent context windows are finite. Every tool result, every model response, every scraped page gets appended to messages. Eventually you overflow.

The common fix — truncating the oldest messages — throws away the system prompt and the user's original request, which are exactly what you need most.

Unstuck condenses old work instead:

from src.memory import SmartMemory

memory = SmartMemory(max_messages=12, summary_every=6)

The agent keeps working with a short, accurate summary instead of a giant transcript. You lose verbatim history, but you keep the decisions — which is what actually matters for the next step.

This is the most embarrassing failure mode: an agent tries to edit a file, the edit fails, it tries the same edit again, fails again, and repeats until the run is killed. I've watched agents burn through $2 of API credits on the same broken command.

Unstuck halts on repetition:

from src.loop_alarm import LoopAlarm

alarm = LoopAlarm(max_repeats=3)

while True:
    action = agent.decide()
    if alarm.seen(action):
        alarm.halt("Same action repeated 3 times. Waiting for human.")
        break
    result = tool.execute(action)
    alarm.record(action, result)

Three identical actions and the agent stops, hands control back, and asks. No infinite spins, no surprise bills.

Agents write code. Agents break code. Without checkpoints, a bad edit is permanent.

Unstuck checkpoints before every mutation:

from src.undo import CheckpointManager

checkpoints = CheckpointManager()

before = file.read()
checkpoints.save("edit-1", before)

try:
    file.write(agent_edit(before))
except Exception:
    file.write(checkpoints.restore("edit-1"))
    raise

One click restores the last good state. No git knowledge required, no manual git checkout.

Unstuck is stdlib-only — no keys, no internet, no npm install:

python -m venv .venv
.venv\Scripts\activate
python examples/quickstart.py

Copy src/ into your project:

from src.waiter import PoliteWaiter
from src.memory import SmartMemory
from src.loop_alarm import LoopAlarm
from src.undo import CheckpointManager

That's the whole integration. Four classes, under 300 lines total.

The roadmap: async waiter with a token-bucket queue (so parallel agents share a rate limit), embedding-based loop detection (similar actions, not just identical), and git-native checkpoints. All of these solve the same four pains at a larger scale.

But the core lesson is already there: agents don't need to be complex to be reliable. They need to handle rate limits politely, summarize memory, halt on loops, and undo bad edits. Everything else is bonus.

── more in #ai-agents 4 stories · sorted by recency
── more on @unstuck 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/agents-that-don-t-qu…] indexed:0 read:3min 2026-11-29 · —