Leave a coding agent running overnight: timeouts and retries
Updated 10 November 2026
An agent you can leave alone is the main reason to want a flat rate: no meter running and no window to run out of at 3am. A few settings decide whether it actually keeps going. None of them are exotic, and most are already in the setup commands.
The limits to design around
| Limit | What to know |
|---|---|
| Request length | A single request can run for up to 15 minutes. Very long generations need a tool timeout above that. |
| Output per request | Capped by your plan (the setup commands set it for you). A response that hits it ends with a finish reason of length, so ask for smaller steps. |
| Context window | Input plus output must fit in your plan's window. Agents that compact when they get close, as Claude Code does, are fine. See the context fix. |
| Parallel streams | Requests beyond your plan wait in a short queue, then get a 429. Cap an overnight job to its own key so it can't crowd out anything else. |
| Free plan | A small daily allowance. Fine for trying it, not for a night's work. |
Settings that matter
- A generous request timeout. Requests can wait briefly in the queue before they start, and one can run for up to 15 minutes. The Claude Code setup uses
API_TIMEOUT_MS=600000(10 minutes, Claude Code's own default), so for very long generations open~/.nevermetered-claude.shand raise it to900000or more. Use the same idea in other tools. - Cut optional background traffic.
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1(already in the setup) removes small background requests such as session titles. - A dedicated, capped key. One stream is plenty for a single overnight agent: see one key per project.
- Retries with backoff for 429 and 503. A 429 for too many streams at once carries
Retry-After: 1; a 429rate_limit_exceededcarries a longer wait (10 seconds); a daily-allowance 429 has noRetry-After, so retrying won't help until the reset. A 503 means the service was busy or short of capacity and is worth retrying after a short wait. Don't blindly retry other errors: a 400, 401, 413 or a 504max_stream_durationwill fail the same way every time.
Running Claude Code without sitting at it
claude -p runs one prompt and exits, so you can drive it from a script or a scheduled job. Using the command from the second-lane guide:
nevermetered-claude -p "Run the test suite, fix any failures you find, and summarise what you changed"A plain API call that retries itself
For scripts that call the API directly, curl's --retry repeats a request after the transient failures (timeouts and 408, 429, 500, 502, 503 or 504 responses) and waits for any Retry-After the server sends. It does not retry errors like a bad key or a wrong model name. One caveat: a generation is not idempotent, so if a connection drops after the request was accepted, a retry can run it a second time. That is harmless for a read-only prompt, so think twice if your script acts on the result.
curl --retry 5 --retry-delay 2 \
https://api.nevermetered.com/v1/chat/completions \
-H "Authorization: Bearer $NEVERMETERED_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "qwen3.8-27b", "messages": [{"role": "user", "content": "Reply with the word ready"}]}'Checking on it in the morning
- 1
Open Requests and filter by the agent's key
A steady run of
ok 200rows means it kept going. Gaps show where it stalled. - 2
Look for errors on Usage
The Usage page counts failures and cancellations, and the 429s that were rejected.
- 3
Check Peak parallel
If the capped key sat at its cap all night, its requests were queuing behind each other. That's fine for a single agent, and the reason to give it a key of its own.
Can the agent run forever?
Will my agent hog all my streams?
What if the service restarts mid-run?
- NeverMetered pricing and plan limits (checked 10 November 2026)
- NeverMetered docs: Claude Code setup (checked 10 November 2026)