Pouria Mojabi, AI Strategy Advisor and Startup Consultant
Pouria Mojabi AI Strategy & Startup Advisor mojabi.io
← All Bits
🔥 AI / Tech Mar 31, 2026

A Silent Cron Loop Burned My AI Token Budget in 20 Min

A Silent Cron Loop Burned My AI Token Budget in 20 Min

The Setup

I run OpenClaw, an AI agent orchestration layer. My setup has multiple agents — a COO agent (Pandy), a CTO agent (R20), and a bunch of automated cron jobs: morning briefings, nightly heartbeats, memory consolidation, journal writing. Standard ops for anyone running AI agents seriously.

Each agent runs on a different model. Pandy runs on Claude Opus 4.6. R20 runs on GPT-5.4. The cron jobs fire into isolated sessions so they don't step on each other.

At least, that's how it was supposed to work.

The Bug

Here's what actually happened:

Several cron jobs had a stale sessionKey pointing to my main interactive session — agent:main:main. This meant that when cron jobs fired, the gateway checked the main session's model state before launching the isolated run.

The main session had seen traffic from multiple agents running different models: Opus 4.5, Opus 4.6, Sonnet 4.5, Sonnet 4.6, GPT-5.4. The gateway's model-resolution logic saw a mismatch between the configured model and the session's last-used model, and triggered a LiveSessionModelSwitchError.

Instead of failing gracefully, it retried. And retried. And retried.

For 20 minutes straight, the gateway cycled through model fallbacks every 25-90 seconds:


opus-4-5 → opus-4-6
sonnet-4-5 → opus-4-6  
sonnet-4-6 → opus-4-6
gpt-5.4 → opus-4-6

Each retry sent the full system prompt to the API. My system prompt is ~48KB of workspace files, tool definitions, and skill registrations. At Opus pricing, ~20 retry cycles × 60k+ input tokens each = my entire daily budget gone in minutes.

No output. No useful work. Just the same prompt hitting the API wall over and over.

What Made It Worse

Three things compounded the damage:

  1. No circuit breaker. The retry loop had no max-attempts limit. It would have run until the rate limiter or my wallet said stop.
  2. Silent failure. No alert fired. No notification. The gateway logs showed it happening in real-time, but nothing surfaced it to me. I only noticed when Anthropic's usage dashboard showed the spike.
  3. Fat system prompt. My system prompt had grown organically — MEMORY.md (10KB), SOUL.md (6.5KB), HEARTBEAT.md (4.7KB), TOOLS.md (4.7KB), PLAYBOOKS.md (11.6KB), plus QUEUE.md (4.6KB). That's ~48KB of workspace files alone, before tool definitions and skill registrations. Every retry sent all of it.

The Fix

Immediate:

Structural:

Missing safeguards that should exist:

The Lesson

AI agent infrastructure is production infrastructure. It needs the same operational discipline as any other system — and managing API costs is table stakes:

The irony is that I build AI products for a living. I've scaled systems to millions of users. And a misconfigured cron job ate my token budget while I was at dinner.

If you're running AI agents in production — especially multi-agent setups with mixed models — audit your session bindings today. Build in crash recovery and watch for context drift. The bug that gets you won't be the complex one. It'll be a stale reference in a config nobody looked at.


Continue Reading


← More Bits