mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
fix(ai): do not retry Zhipu usage limit errors (code 1308) (#11572)
When a Zhipu/Z.ai (`open.bigmodel.cn`) plan hits its usage cap, the API
returns HTTP 429 with error code `1308`. The cap resets after hours, but
`isRetryableAssistantError()` still marked the error as retryable,
because the bare `429` in the message matched the transient-error
pattern. The agent-level retry then re-sent a request that could not
succeed and slowed down the final error. With default settings that is 3
attempts, about 14 s.
This change adds the Zhipu `"code":"1308"` error code to the
non-retryable provider-limit patterns in
`packages/ai/src/utils/retry.ts`, next to the existing quota and
subscription-limit entries. The pattern matches the JSON code field, not
a bare number, so request IDs or byte counts that contain 1308 do not
trigger it.
Not changed: the provider-level HTTP retry (`retry.provider.maxRetries`,
off by default). It still retries every 429 based on the status code
alone.
Testing:
- `npm run check` passes.
- `test/retry.test.ts` passes.
- Calling `isRetryableAssistantError` directly on the reported message,
`429 {"code":"1308","message":"已达到 5 小时的使用上限。…"}`, returned `true`
before the change and returns `false` after.
Fixes #11537
Requested by @davidbrai
Co-authored-by: triagent <triagent@localhost>
This commit is contained in:
parent
f14813e965
commit
c719d5b08e
1 changed files with 4 additions and 0 deletions
|
|
@ -28,6 +28,10 @@ const NON_RETRYABLE_PROVIDER_LIMIT_ERROR_PATTERN = buildProviderErrorPattern([
|
|||
// Sign in with ChatGPT on a ChatGPT Business plan: a usage limit set by the
|
||||
// workspace admin. Only the admin can raise it.
|
||||
"subscription_sharing_workplace_individual_usage_limit_exceeded",
|
||||
|
||||
// Zhipu/Z.ai (open.bigmodel.cn) error code 1308: the plan's usage limit is
|
||||
// reached, sent as HTTP 429. It resets after hours, not seconds (#11537).
|
||||
'"code"\\s*:\\s*"?1308(?![0-9])',
|
||||
]);
|
||||
|
||||
const RETRYABLE_PROVIDER_ERROR_PATTERN = buildProviderErrorPattern([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue