Commit Graph

2 Commits

Author SHA1 Message Date
Xiangzhe
d37a389203 feat(sse): surface provider rule lock scope from checkFallbackError (agentrouter-only)
Add honorsRuleLockScope() as an exclusive allowlist (agentrouter today) and
surface the matched ProviderErrorRule's scope as checkFallbackError's new
ruleScope field. The agentrouter 403 path now consults the provider rules
before the generic apikey-FORBIDDEN early-return, so a recognized body like
"无权访问模型" carries the rule's declared reason/cooldown/scope instead of
the generic short auth cooldown. Every other provider's behavior is
unchanged — ruleScope stays undefined outside the allowlist.
2026-08-14 13:18:32 -03:00
Diego Rodrigues de Sa e Souza
20ea78c943 feat(sse): restate agentrouter quota 403/400 as retryable 429 with provider-scoped error rules (#10335)
agentrouter.org signals temporary quota exhaustion with HTTP 403/400 and a Chinese body (用户额度不足) instead of 429, so clients like Claude Code treat it as permanent and abort, and the fallback engine classified it as a generic apikey AUTH_ERROR.

New registry open-sse/config/upstreamStatusRestatement.ts restates those statuses to 429 with a synthetic Retry-After at a single hook in chatCore's providerFailure block (after parseUpstreamError), so classification, combo aggregation and the client response all see a retryable error. 无权访问模型 (permanently no model access) is veto-listed and never restated.

agentrouter classification rules are registered in providerErrorRules.ts and reach the real checkFallbackError path through resolveRuleMatchBody() with an exclusive FULL_TEXT_RULE_PROVIDERS allowlist — every other provider keeps its previous behavior byte-for-byte.

Known limitations tracked in #10334: the rules' scope field is informational (persistence applies per-model lockout for agentrouter), the 403-only model-access rule has no production path yet, and errors embedded in 200 SSE streams are not restated.

Refs #10334
2026-08-14 12:42:58 -03:00