CommandCodeAI / CommandCodeAI/command-code

Respect Retry-After header for BYOK 429 responses

未關閉
#788 2 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

@ahmadbilaldev 已經在處理了。

開始於 2026年9月2日。

主要語言
沒有語言資料
星號
4k
分支
350
PR 合併指標
30 天內沒有已合併 PR

描述

Feature Description

Add support for the upstream Retry-After header when retrying HTTP 429 responses from BYOK providers.

Some inference providers use rolling/sliding token rate limits and return a Retry-After header indicating the minimum amount of time the client should wait before sending another request.

When Retry-After is present on a 429 response, CommandCode should wait at least for the duration specified by the provider before retrying.

Suggested behavior:

  1. Preserve the upstream Retry-After header on BYOK HTTP 429 responses.
  2. Parse both standard forms of Retry-After:
    • delay in seconds;
    • HTTP date.
  3. Wait at least for the duration specified by Retry-After.
  4. If subsequent 429s occur, use exponential backoff with jitter.
  5. If Retry-After is absent, fall back to the existing retry/backoff behavior.
  6. Avoid immediate or parallel retries while the provider has explicitly requested the client to wait.

This should apply to upstream/BYOK rate limiting and should not change the existing handling of CommandCode's own recognized usage-window limits.

Use Case

I encountered this while using GLM-5.3-Flash through a BYOK provider.

My typical workload consists of long-running coding and reverse-engineering sessions (Ghidra/disassembly). As a session progresses, individual model requests commonly reach 100k–150k+ input tokens.

Baseten enforces its TPM limit per model across the workspace using a rolling/sliding window. Their support confirmed that HTTP 429 responses include a Retry-After header with the minimum time the client should wait before retrying.

During one real CommandCode session, the Baseten dashboard recorded:

  • 22 successful responses (HTTP 200)
  • 88 rate-limited requests (HTTP 429)

From the CommandCode UI, it appeared that the client was repeatedly reconnecting/retrying while the provider was still rate-limited.

With a 100k–150k token request, retrying too early is particularly inefficient because the provider may still not have enough capacity available in its rolling TPM window for the request.

Respecting Retry-After would allow CommandCode to pause once, resume when the provider indicates capacity should be available, and avoid large numbers of unnecessary retry attempts.

This would also make BYOK integrations behave better with other inference providers that use standard HTTP 429 + Retry-After rate-limit semantics.

Additional Context

I contacted provider's support to clarify the behavior. They confirmed:

The 500k TPM limit is enforced per model across the workspace, rather than per API key, client session, or context.

The limit uses a rolling/sliding window rather than a fixed reset at the top of each minute.

On a 429, the API should return a Retry-After header indicating the minimum number of seconds to wait. We recommend respecting that value and using exponential backoff with jitter rather than retrying at a fixed interval or immediately.

They specifically recommended the following client behavior:

  • Read and follow Retry-After when present.
  • Apply exponential backoff with jitter for subsequent 429s.
  • Avoid parallel or immediate retries.

The high number of 429s was visible directly in the provider dashboard: 22 successful responses vs. 88 HTTP 429 responses during the test period.

How important is this to you?

Not critical, but important

貢獻指南

這個儲存庫沒有索引到貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。