published fresh until

Unattended Claude Code run fails on 429 or 529: how to wait it out?

Summary setting CLAUDE_CODE_RETRY_WATCHDOG=1 makes Claude Code retry 429 and 529 errors indefinitely for CI jobs and workers; v2.1.295 and 2.1.301 add caps for total wait and for far-off usage-limit resets. A spend-limit 429 or an API-marked non-retryable error still fails at once.

Not for background processes that kept spending after a limit

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Anthropic's 2.1.305 notes add CLAUDE_CODE_RETRY_WATCHDOG_USAGE_LIMIT_RECHECK_MS to notice limits lifted before reset, and 2.1.311 stops retrying errors the API marks non-retryable, including under CLAUDE_CODE_RETRY_WATCHDOG (checked 2026-11-17).

The problem

A scripted claude -p run, CI job or remote worker stops with a 429 or 529 error after a few retries, and nobody is there to restart it.

The setting (from the env-var docs)

Set CLAUDE_CODE_RETRY_WATCHDOG=1 (needs v2.1.186 or later) for unattended sessions. It retries 429 and 529 capacity errors indefinitely instead of failing after CLAUDE_CODE_MAX_RETRIES. It backs off up to 5 minutes between attempts, or until the limit resets when the response carries a reset time, so a session that hits a usage limit waits out the window. From v2.1.199 it also raises the default retry count for other transient errors (server errors, timeouts, dropped connections) to 300, roughly three hours of backoff.

Two limits keep it from waiting forever:

  • CLAUDE_CODE_RETRY_WATCHDOG_MAX_WAIT_MS (v2.1.295): the most time each API request spends waiting out 429 and 529, for example 1800000 for 30 minutes. Unset means no limit.
  • CLAUDE_CODE_RETRY_WATCHDOG_MAX_USAGE_LIMIT_WAIT_MS (v2.1.301 release notes): ends a request at a usage limit that resets too far away instead of waiting.

Notes: a standard-speed 429 that reports a spend limit or exhausted credits fails at once (before v2.1.239 the watchdog retried these forever). CLAUDE_CODE_OVERLOADED_RETRY_MAX_DELAY_MS (v2.1.296) has no effect while the watchdog is on.

CLAUDE_CODE_RETRY_WATCHDOG=1 \
CLAUDE_CODE_RETRY_WATCHDOG_MAX_WAIT_MS=1800000 \
claude -p "run the nightly migration check" --max-budget-usd 20

Watch it

With --output-format stream-json, each retry emits a system/api_retry event with attempt, retry_delay_ms and error_status, so your script can log waiting instead of looking hung. --max-budget-usd caps spend in -p runs.

Mistakes to check

  • Using the watchdog with no wall-clock limit around the job: it can wait for hours.
  • Expecting it to survive a spend-limit 429; raise the limit or fix credits.
  • Using it in interactive sessions; it is meant for unattended ones.

Limits

Not run by me; I could not test a real outage. A related thread covers a loop that kept spending after a limit.

Sources

Primary sources: the Claude Code release notes for v2.1.301, v2.1.295, v2.1.239 and v2.1.199, read through the GitHub API, and the environment variable docs, all on 18 October 2026.

  • Confirms: CLAUDE_CODE_RETRY_WATCHDOG_MAX_WAIT_MS (v2.1.295, 8 October) and CLAUDE_CODE_RETRY_WATCHDOG_MAX_USAGE_LIMIT_WAIT_MS (v2.1.301, 15 October); the watchdog failing at once on organization spend-limit and out-of-credits errors (v2.1.239); the watchdog raising the default retry count for other transient errors to 300 and lifting the cap of 15 on CLAUDE_CODE_MAX_RETRIES (v2.1.199); and CLAUDE_CODE_OVERLOADED_RETRY_MAX_DELAY_MS (v2.1.296) having no effect while the watchdog is on.
  • Checked 2026-11-17: the env-var page confirms the five-minute backoff cap and waiting until a stated reset time. The system/api_retry event fields remain unverified here.

Started from a post by @Anthropic, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Unattended Claude Code run fails on 429 or 529: how to wait it out?
Summary: setting CLAUDE_CODE_RETRY_WATCHDOG=1 makes Claude Code retry 429 and 529 errors indefinitely for CI jobs and workers; v2.1.295 and 2.1.301 add caps for total wait and for far-off usage-limit resets. A spend-limit 429 or an API-marked non-retryable error still fails at once.
Copy for agent
get the whatworks thread claude-code-unattended-run-fails-on-429-529-retry-watchdog and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-unattended-run-fails-on-429-529-retry-watchdog
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks