| 1 | # HTTP rate-limit retries |
| 2 | |
| 3 | `[retry.rate_limit]` configures the native HTTP transport's recovery loop: |
| 4 | |
| 5 | ```toml |
| 6 | [retry.rate_limit] |
| 7 | max_attempts = 20 |
| 8 | recovery_budget_secs = 600 |
| 9 | initial_delay_secs = 5 |
| 10 | max_delay_secs = 60 |
| 11 | ``` |
| 12 | |
| 13 | These are engineering defaults. They do not assert a provider-wide recovery |
| 14 | percentile. The budget starts at the first rate refusal, counts the initial HTTP |
| 15 | attempt, and is independent of the existing network/5xx retry count. Backoff |
| 16 | doubles to a local ceiling of 60 seconds, with equal jitter over 50–100% of the |
| 17 | base. The greater of the local delay and the server minimum is used, with |
| 18 | additional jitter of half the local delay when a nonzero minimum is present. |
| 19 | |
| 20 | The legacy `[retry]` backoff fields (`initial_delay`, `max_delay`, |
| 21 | `exponential_base`, `jitter`, `jitter_factor` and `respect_retry_after`) do not |
| 22 | override this 429 policy. In particular, `respect_retry_after = false` does not |
| 23 | suppress server minima and `jitter = false` does not disable rate-limit jitter. |
| 24 | `max_retries` counts ordinary transport retries; `max_retries = 0` alone does |
| 25 | not disable 429 recovery. Use `retry.rate_limit.max_attempts = 1` to disable only |
| 26 | automatic 429 retries, or `retry.enabled = false` to disable this HTTP retry loop. |
| 27 | The existing safe pre-dispatch HTTP/1.1 fallback inside a stream-opening operation |
| 28 | remains possible. |
| 29 | |
| 30 | All four rate-limit fields are validated when configuration loads: |
| 31 | `max_attempts` must be `1..=1000`, `recovery_budget_secs` must be `1..=86400`, |
| 32 | and `1 <= initial_delay_secs <= max_delay_secs <= 86400`. Invalid values fail |
| 33 | loading rather than silently changing these bounds. The actual pause/sleep |
| 34 | limit below still applies even when a longer recovery budget is configured. |
| 35 | |
| 36 | Numeric and HTTP-date Retry-After values and recognized JSON reset fields are |
| 37 | supported. A minimum beyond the remaining recovery budget is returned to the |
| 38 | caller immediately, without shortening it to the local backoff ceiling. Native |
| 39 | MiniMax/Zhipu JSON success envelopes carrying a failure use the same policy and |
| 40 | the caller's existing error-disclosure boundary. Known quota windows, billing |
| 41 | and invalid-input failures are not short-retried. Server-directed provider pauses and |
| 42 | automatic retry sleeps are limited to 3600 seconds, including sub-agents. Longer |
| 43 | minima remain attached to the returned error as advice; the current operation |
| 44 | stops rather than retrying before that minimum. Quota-window errors distinguish |
| 45 | a server rejection from admission that did not dispatch a request and do not |
| 46 | claim that this transport slice saved a checkpoint. |
| 47 | |
| 48 | Backoff does not consume the active HTTP envelope. The request's existing body |
| 49 | timeout still bounds a stalled non-streaming response. Native JSON envelope |
| 50 | inspection has a 32 MiB size limit and applies the caller's first-byte and inter-chunk idle deadlines. Ordinary SSE body and idle recovery |
| 51 | remain owned by the existing stream adapter. Dropping the operation |
| 52 | cancels its wait. `retry.enabled = false` still runs a transport operation once. |
| 53 | |
| 54 | This contribution changes the common native HTTP transport loop, its isolated |
| 55 | preview classifier, retry clock and typed errors. The separately implemented |
| 56 | legacy vision adapter is outside this transport slice; no shared task/admission |
| 57 | workflow is claimed for that adapter. It does |
| 58 | not introduce a task scheduler, persisted checkpoints, host UI events, shared |
| 59 | task-operation budgets across outer stream retries, or a new task outcome |
| 60 | policy. Those remain responsibilities of the calling engine/host. A successful |
| 61 | transport retry is not evidence that a host's complete task recovery workflow |
| 62 | has been verified. |
| 63 |