TL;DR

I run a fully autonomous coding agent that kicks off scheduled jobs around the clock, and for months I didn't have a real plan for what happens when the LLM provider says "no more requests right now." Eventually it happened enough times that I had to design for it properly. Here's what I learned about detecting rate limits, failing fast instead of retry-looping, and making every scheduled run safe to skip.

The Problem

When you run an AI agent as a background worker instead of an interactive chat session, you stop thinking about rate limits as an edge case and start thinking about them as a certainty. Somewhere, on some day, a scheduled run is going to hit a provider-side cap — a session limit, a rolling 5-hour window, a hard 429 — and your agent needs to have an opinion about what happens next.

My setup is simple on paper: a background job wakes up once a day, spins up an autonomous coding agent, and lets it do a scoped chunk of work — writing code, updating state, whatever the day's task is. No human watches it run. That's the whole point of "autonomous." But "no human watches it run" cuts both ways: if the agent gets a 429 and responds by hammering the API in a tight retry loop, there's nobody there to notice until the bill shows up or the account gets flagged.