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

LimitWhat to know
Request lengthA single request can run for up to 15 minutes. Very long generations need a tool timeout above that.
Output per requestCapped 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 windowInput 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 streamsRequests 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 planA 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.sh and raise it to 900000 or 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 429 rate_limit_exceeded carries a longer wait (10 seconds); a daily-allowance 429 has no Retry-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 504 max_stream_duration will 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. 1

    Open Requests and filter by the agent's key

    A steady run of ok 200 rows means it kept going. Gaps show where it stalled.

  2. 2

    Look for errors on Usage

    The Usage page counts failures and cancellations, and the 429s that were rejected.

  3. 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?
Paid plans have no token quota, 5-hour window or weekly cap, so there is no limit that runs out. What can stop it is a bad setting (a timeout that's too short), a context window it can't compact out of, or a service interruption. Check the status page if a run stops unexpectedly.
Will my agent hog all my streams?
Only if its key allows it. Give it a key capped at 1 so your interactive work always has a stream free.
What if the service restarts mid-run?
A request that's in flight can fail with a 5xx. Your tool should retry it. Most agent tools do this automatically; if yours doesn't, wrap the call as above.
Sources