You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7942348
Browse filesBrowse the repository at this point in the historyBrowse files
fix(retry): bound every retry wait at 5 minutes (#175)
A retryable error of any status whose Retry-After / retry-after-ms asks
for longer than USAGE_LIMIT_MAX_WAIT (5 minutes) is no longer retried:
429s still fail as a usage limit (#174), other statuses fail with the
provider error. delay() caps a requested wait at the same bound, and the
hintless exponential backoff stops at 30 s whether or not the response
has headers. RETRY_MAX_DELAY_NO_HEADERS is renamed RETRY_MAX_BACKOFF
since it now applies to every response.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015nwvfUHdM3bgMgD9Zpz7Mj
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@
5
5
### Fixes
6
6
7
7
-**Messages written in the same millisecond keep their order** — Reading a session's messages now breaks `time_created` ties by message ID. Before, messages written in the same millisecond came back oldest first. A compaction writes its request, its summary and the continue message in quick succession, so the prompt loop could miss the finished summary and compact again, sending an extra model request. (#200)
8
+
-**Retry waits are bounded for every status** — No single wait between retries exceeds 5 minutes. A retryable error of any status whose `Retry-After` / `retry-after-ms` asks for longer is no longer retried: a 429 still fails as `usage_limit` (#174), and any other status (for example a 503 or 529 asking for `retry-after: 18000`, which used to sleep about 5 hours per attempt) fails at once with the provider error, `session_error.reason` from its status (`provider` for a 5xx) and exit 1, with no `retry` event. Exponential backoff without a retry hint now stops at 30 s even when the response has headers, as every AI SDK HTTP error does, so a hintless 429 or 5xx retries for about 3.5 minutes in all instead of about 34. With 10 retries the waits total at most 50 minutes. (closes #175)
-`resetAt` (number, optional) — for `usage_limit`, when the provider said the limit resets, in Unix milliseconds. It comes from `Retry-After` / `retry-after-ms`, or from the reset time in a Z.ai quota message. Omitted when the provider gave no reset time the CLI can read, or one too far away to be a valid date.
179
179
180
-
**Provider usage limits.** A provider usage or quota limit that will not reset soon fails the run immediately instead of retrying. The bound is 5 minutes: `MAX_RETRY_ATTEMPTS` (10) times the 30-second header-less delay cap. A limit is recognised when:
180
+
**Provider usage limits.** A provider usage or quota limit that will not reset soon fails the run immediately instead of retrying. The bound is 5 minutes: `MAX_RETRY_ATTEMPTS` (10) times the 30-second backoff cap. A limit is recognised when:
181
181
182
182
- an HTTP 429 response has a `Retry-After` or `retry-after-ms` header asking for a single wait longer than 5 minutes, or
183
183
- an HTTP 429 response has a known quota-exhausted shape. Currently this is the Z.ai GLM Coding Plan rolling five-hour (`1308`) and weekly or monthly (`1310`) quota codes, or a `Usage limit reached for <n> hour` message. Z.ai gives the reset only in the message, as `reset at YYYY-MM-DD HH:MM:SS` with no time zone. The CLI reads it as UTC+8 (a fixed `+08:00` offset). A quota whose reset is 5 minutes away or less still retries. A quota whose reset is missing or cannot be read fails fast without `resetAt`.
184
184
185
-
The run emits no `retry` event. The failed turn ends with an `error` status, `session_error` has `reason: "usage_limit"` and `code: "PROVIDER_USAGE_LIMIT"`, and `invocation_complete.status` is `error`. Headless execution exits 1. The message starts with `Provider usage limit reached` and keeps the provider's text, which can name its own reset time. Any other 429 still retries as `rate_limited`: one that asks for a wait of 5 minutes or less, a known quota that resets within 5 minutes, or one with no reset hint and no known quota shape. Those retries keep the existing delays. Each attempt waits for the provider's requested delay, or for exponential backoff when the response gives none, so a run of retries can last longer than 5 minutes in total.
185
+
The run emits no `retry` event. The failed turn ends with an `error` status, `session_error` has `reason: "usage_limit"` and `code: "PROVIDER_USAGE_LIMIT"`, and `invocation_complete.status` is `error`. Headless execution exits 1. The message starts with `Provider usage limit reached` and keeps the provider's text, which can name its own reset time. Any other 429 still retries as `rate_limited`: one that asks for a wait of 5 minutes or less, a known quota that resets within 5 minutes, or one with no reset hint and no known quota shape. Those retries follow the bounded delays described under [`retry`](#retry).
186
186
187
187
```json
188
188
{
@@ -198,7 +198,7 @@ The run emits no `retry` event. The failed turn ends with an `error` status, `se
198
198
199
199
### `retry`
200
200
201
-
Emitted when a primary-session model attempt fails with a retryable error and the CLI schedules another attempt. This includes a thought-only `unknown` finish with no tool call or non-empty text. It is not emitted after retries are exhausted, for a provider usage limit (see `session_error`), or for an `unknown` finish that includes text or a tool call.
201
+
Emitted when a primary-session model attempt fails with a retryable error and the CLI schedules another attempt. This includes a thought-only `unknown` finish with no tool call or non-empty text. It is not emitted after retries are exhausted, for a provider usage limit (see `session_error`), for a provider-requested wait over 5 minutes (see Retry delays below), or for an `unknown` finish that includes text or a tool call.
202
202
203
203
```json
204
204
{
@@ -218,6 +218,8 @@ Emitted when a primary-session model attempt fails with a retryable error and th
218
218
-`retry.code``rate_limited` maps to `session_error.reason``rate_limit`; `no_finish_reason`, `overloaded`, `server_error`, and `network` are retry-only codes.
219
219
-`next` (number, **required**) — scheduled next-attempt time in Unix milliseconds.
220
220
221
+
**Retry delays.** No single wait between attempts exceeds 5 minutes, whatever the status code or headers. Each retry waits for the provider's `Retry-After` / `retry-after-ms` when it sends one, or else for exponential backoff of 2 s, 4 s, 8 s and 16 s, then 30 s for each later attempt. A retryable error whose provider asks for a wait longer than 5 minutes is not retried: a 429 fails as a provider usage limit (see `session_error`), and any other status (for example a 503 or 529 "overloaded" with `retry-after: 18000`) fails with that provider error, so `session_error.reason` is classified from its status as usual (`provider` for a 5xx). Neither emits a `retry` event. With at most 10 retries, the waits total at most 50 minutes when every response asks for 5 minutes, and 3.5 minutes (210 s) when no response gives a retry hint.
222
+
221
223
### `message_complete`
222
224
223
225
Emitted when a primary-session assistant message finishes (one per LLM turn). Child-session assistant messages are
@@ -290,6 +292,7 @@ An `unknown` finish is triaged by delivered output. Nonempty text becomes `stop`
290
292
| Other nonempty finish | Existing behavior: end the loop without inferring failure from an unfamiliar reason. |
| Provider usage limit | Not retried for a 429 that waits over 5 minutes or is a known quota without a sooner reset; `usage_limit` and exit 1. |
295
+
| Long provider-requested wait | Not retried for any other status that waits over 5 minutes; the provider error fails the run and exits 1. |
293
296
| Cancellation / stream timeout | Existing cancellation and timeout lifecycle; not reclassified as a provider finish error. |
294
297
295
298
With pinned Google SDK 2.0.54, `IMAGE_SAFETY`, `RECITATION`, `SAFETY`, `BLOCKLIST`, `PROHIBITED_CONTENT`, and `SPII` map to `content-filter`; `MALFORMED_FUNCTION_CALL` maps to `error`. `OTHER` and `FINISH_REASON_UNSPECIFIED` map to `other`, while `LANGUAGE` maps to `unknown`. These last mappings retain the behavior above; they do not prove successful task completion. Consumers can distinguish `other` from `stop` using `message_complete.finish`.
0 commit comments