Skip to content

fix: add CJK quota-exhaustion patterns to 429 classifier - #13536

Closed
KooshaPari wants to merge 2 commits into
diegosouzapw:release/v3.8.51from
KooshaPari:pr/13194-cjk-quota-patterns
Closed

KooshaPari wants to merge 2 commits into
diegosouzapw:release/v3.8.51from
KooshaPari:pr/13194-cjk-quota-patterns

Conversation

@KooshaPari

Copy link
Copy Markdown
Contributor

Fixes #13194

Changes

  • Added CJK (Chinese) quota-exhaustion patterns to both QUOTA_PATTERNS and TERMINAL_QUOTA_PATTERNS in classify429.ts
  • Covers z.ai/GLM, Kimi/Moonshot, Qwen/DashScope, and MiniMax error messages
  • Patterns match: 使用上限, 额度已用尽, 额度已用完, 调用上限, 已达上限, 余额不足

Root Cause

CJK providers return Chinese error bodies for quota exhaustion that none of the English-only patterns matched, causing the 429 classifier to treat long-window quota exhaustion as transient rate_limit (60s cooldown) instead of quota_exhausted (long cooldown + failover).

Koosha Pari added 2 commits September 13, 2026 02:21
…ns inflation (diegosouzapw#13364)

When a client sends a model like 'zed-hosted/claude-haiku-4-5-20251001', the
provider prefix was passed through to openaiToClaudeRequest unchanged. The
capability lookup in fitThinkingToMaxTokens uses static MODEL_SPECS keyed by
bare model id, so a prefixed name silently misses the output cap (64000 for
Haiku 4.5) and causes max_tokens inflation: 32000 + 131072 = 163072, which
Anthropic rejects with 'max_tokens: 163072 > 64000'.

Strip the provider prefix before passing the model to translators, the wire
payload, and the stream wrapper so capability lookups resolve correctly.

Fixes diegosouzapw#13364
…souzapw#13194)

CJK providers (z.ai/GLM, Kimi, Qwen, MiniMax) return Chinese error
bodies that none of the English patterns match, causing the gateway
to classify long-window quota exhaustion as transient rate_limit.
Added Chinese patterns for usage limit, quota exhausted, call limit,
and insufficient balance to both QUOTA_PATTERNS and
TERMINAL_QUOTA_PATTERNS.
Copilot AI lite review requested due to automatic review settings September 13, 2026 09:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@diegosouzapw

Copy link
Copy Markdown
Owner

Thanks! #13412, also from you, covers #13194 with a broader pattern set and tests, and it is being merged. This branch also carries the #13537 zed commit, which does not compile.

It also adds the CJK patterns to TERMINAL_QUOTA_PATTERNS. That would make GLM's recoverable 5-hour window ("已达到 5 小时的使用上限…将在…重置") terminal instead of a cooldown. Closing as superseded by #13412.

diegosouzapw pushed a commit that referenced this pull request Sep 15, 2026
…13412)

Adds CJK quota-exhaustion messages (GLM/z.ai 5-hour window, Kimi, Qwen/DashScope, MiniMax, plus Japanese and Korean phrasings) to the 429 quota classifier. They are now `quota_exhausted` (cooldown + failover) instead of a transient `rate_limit` retry loop (#13194). The patterns go into the recoverable `QUOTA_PATTERNS` only, not the terminal set, and a guard case keeps the Chinese transient "请求过于频繁" as `rate_limit`. Chosen over #13536.

Validated in one consolidated batch of this series (37 PRs boarded together on `release/v3.8.51`): `typecheck:core`, `check:open-sse-typecheck` and `check:dashboard-typecheck` clean; ESLint clean on every changed file; file-size, complexity, cognitive-complexity, changelog-integrity, docs-counts, docs-sync and migration-numbering gates green (only the pre-existing `open-sse/utils/stream.ts` file-size red remains, inherited from the base); 3,743 focused `node:test` cases plus 34 vitest cases green.

Thanks @KooshaPari!
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…iegosouzapw#13412)

Adds CJK quota-exhaustion messages (GLM/z.ai 5-hour window, Kimi, Qwen/DashScope, MiniMax, plus Japanese and Korean phrasings) to the 429 quota classifier. They are now `quota_exhausted` (cooldown + failover) instead of a transient `rate_limit` retry loop (diegosouzapw#13194). The patterns go into the recoverable `QUOTA_PATTERNS` only, not the terminal set, and a guard case keeps the Chinese transient "请求过于频繁" as `rate_limit`. Chosen over diegosouzapw#13536.

Validated in one consolidated batch of this series (37 PRs boarded together on `release/v3.8.51`): `typecheck:core`, `check:open-sse-typecheck` and `check:dashboard-typecheck` clean; ESLint clean on every changed file; file-size, complexity, cognitive-complexity, changelog-integrity, docs-counts, docs-sync and migration-numbering gates green (only the pre-existing `open-sse/utils/stream.ts` file-size red remains, inherited from the base); 3,743 focused `node:test` cases plus 34 vitest cases green.

Thanks @KooshaPari!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants