Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(taskfailure): classify explicit insufficient balance as quota (#11000)
Danila Katalshov72286e56ed02
diff --git a/apps/docs/content/docs/tasks.fr.mdx b/apps/docs/content/docs/tasks.fr.mdxindex 96eae098a5..2ef576f878 100644--- a/apps/docs/content/docs/tasks.fr.mdx+++ b/apps/docs/content/docs/tasks.fr.mdx@@ -120,8 +120,8 @@ Le préfixe `agent_error.` est omis dans ce tableau.| Motif | Signification | Que faire || --- | --- | --- || `provider_auth_or_access` | Échec d'authentification ou accès refusé par le fournisseur du modèle (401/403) | Reconnectez-vous dans cet outil de codage IA, ou vérifiez la clé API |-| `provider_quota_limit` | Quota ou solde épuisé (402) | Rechargez le compte ou changez de compte |-| `provider_capacity_or_rate_limit` | Limite de débit atteinte ou capacité insuffisante (429/529) | Réessayez plus tard |+| `provider_quota_limit` | Quota ou solde épuisé | Rechargez le compte ou changez de compte |+| `provider_capacity_or_rate_limit` | Limite de débit atteinte ou capacité insuffisante | Réessayez plus tard || `provider_server_error` | Erreur serveur du fournisseur du modèle (5xx) | Réessayez plus tard || `provider_network` | Échec réseau lors de la connexion au fournisseur du modèle | Relance automatique ; vérifiez le réseau de la machine d'exécution si le problème persiste || `model_not_found_or_unavailable` | Le modèle n'existe pas ou est actuellement indisponible | Choisissez un modèle disponible dans les paramètres de l'agent |diff --git a/apps/docs/content/docs/tasks.ja.mdx b/apps/docs/content/docs/tasks.ja.mdxindex b342e06134..e11484b3fd 100644--- a/apps/docs/content/docs/tasks.ja.mdx+++ b/apps/docs/content/docs/tasks.ja.mdx@@ -120,8 +120,8 @@ import { RunLifecycleDemo } from "@/components/demos/run-lifecycle-demo";| 原因 | 意味 | 対処 || --- | --- | --- || `provider_auth_or_access` | モデルプロバイダーの認証に失敗したか、アクセス権がない(401/403) | その AI コーディングツールで再ログインするか、API キーを確認する |-| `provider_quota_limit` | クォータまたは残高を使い切った(402) | チャージするか、アカウントを切り替える |-| `provider_capacity_or_rate_limit` | レート制限または容量不足(429/529) | 時間をおいてリトライ |+| `provider_quota_limit` | クォータまたは残高を使い切った | チャージするか、アカウントを切り替える |+| `provider_capacity_or_rate_limit` | レート制限または容量不足 | 時間をおいてリトライ || `provider_server_error` | モデルプロバイダー側のサーバーエラー(5xx) | 時間をおいてリトライ || `provider_network` | モデルプロバイダーへのネットワーク障害 | 自動でリトライされる。続く場合は実行マシンのネットワークを確認する || `model_not_found_or_unavailable` | モデルが存在しないか、現在利用できない | エージェント設定で利用可能なモデルを選び直す |diff --git a/apps/docs/content/docs/tasks.ko.mdx b/apps/docs/content/docs/tasks.ko.mdxindex 6a20048e9e..759b9db3fc 100644--- a/apps/docs/content/docs/tasks.ko.mdx+++ b/apps/docs/content/docs/tasks.ko.mdx@@ -120,8 +120,8 @@ import { RunLifecycleDemo } from "@/components/demos/run-lifecycle-demo";| 원인 | 의미 | 처리 방법 || --- | --- | --- || `provider_auth_or_access` | 모델 서비스 인증 실패 또는 접근 권한 없음(401/403) | 해당 AI 코딩 도구에 다시 로그인하거나 API key 확인 |-| `provider_quota_limit` | 사용량 또는 잔액 소진(402) | 충전하거나 계정 변경 |-| `provider_capacity_or_rate_limit` | rate limit 또는 용량 부족(429/529) | 나중에 재시도 |+| `provider_quota_limit` | 사용량 또는 잔액 소진 | 충전하거나 계정 변경 |+| `provider_capacity_or_rate_limit` | rate limit 또는 용량 부족 | 나중에 재시도 || `provider_server_error` | 모델 서비스 오류(5xx) | 나중에 재시도 || `provider_network` | 모델 서비스와의 네트워크 오류 | 자동 재시도됩니다. 계속 발생하면 실행 컴퓨터의 네트워크 확인 || `model_not_found_or_unavailable` | 모델이 없거나 현재 사용할 수 없음 | 에이전트 설정에서 사용 가능한 모델 선택 |diff --git a/apps/docs/content/docs/tasks.mdx b/apps/docs/content/docs/tasks.mdxindex 71bff3615a..eb48001184 100644--- a/apps/docs/content/docs/tasks.mdx+++ b/apps/docs/content/docs/tasks.mdx@@ -120,8 +120,8 @@ The `agent_error.` prefix is omitted in this table.| Reason | Meaning | What to do || --- | --- | --- || `provider_auth_or_access` | Model provider authentication failed or access denied (401/403) | Sign in again in that AI coding tool, or check the API key |-| `provider_quota_limit` | Quota or balance exhausted (402) | Top up or switch accounts |-| `provider_capacity_or_rate_limit` | Rate limited or out of capacity (429/529) | Retry later |+| `provider_quota_limit` | Quota or balance exhausted | Top up or switch accounts |+| `provider_capacity_or_rate_limit` | Rate limited or out of capacity | Retry later || `provider_server_error` | Model provider server error (5xx) | Retry later || `provider_network` | Network failure reaching the model provider | Retries automatically; check the executing machine's network if it persists || `model_not_found_or_unavailable` | The model does not exist or is currently unavailable | Pick an available model in the agent settings |diff --git a/apps/docs/content/docs/tasks.zh-Hant.mdx b/apps/docs/content/docs/tasks.zh-Hant.mdxindex f60b4a0392..a34f6a1c82 100644--- a/apps/docs/content/docs/tasks.zh-Hant.mdx+++ b/apps/docs/content/docs/tasks.zh-Hant.mdx@@ -120,8 +120,8 @@ AI 代理自身返回的錯誤通常不會自動重試。鑑權失效、額度| 原因 | 含義 | 處理 || --- | --- | --- || `provider_auth_or_access` | 模型服務認證失敗或無訪問權限(401/403) | 在該 AI 程式設計工具中重新登入,或檢查 API key |-| `provider_quota_limit` | 配額或餘額用盡(402) | 充值或更換帳號 |-| `provider_capacity_or_rate_limit` | 限流或容量不足(429/529) | 稍後重試 |+| `provider_quota_limit` | 配額或餘額用盡 | 充值或更換帳號 |+| `provider_capacity_or_rate_limit` | 限流或容量不足 | 稍後重試 || `provider_server_error` | 模型服務端錯誤(5xx) | 稍後重試 || `provider_network` | 到模型服務的網路故障 | 會自動重試;持續出現時檢查執行電腦的網路 || `model_not_found_or_unavailable` | 模型不存在或當前不可用 | 在 AI 代理設定中改選可用模型 |diff --git a/apps/docs/content/docs/tasks.zh.mdx b/apps/docs/content/docs/tasks.zh.mdxindex 0e2dc3cfbb..98acd687bd 100644--- a/apps/docs/content/docs/tasks.zh.mdx+++ b/apps/docs/content/docs/tasks.zh.mdx@@ -120,8 +120,8 @@ import { RunLifecycleDemo } from "@/components/demos/run-lifecycle-demo";| 原因 | 含义 | 处理 || --- | --- | --- || `provider_auth_or_access` | 模型服务认证失败或无访问权限(401/403) | 在该 AI 编程工具中重新登录,或检查 API key |-| `provider_quota_limit` | 配额或余额用尽(402) | 充值或更换账号 |-| `provider_capacity_or_rate_limit` | 限流或容量不足(429/529) | 稍后重试 |+| `provider_quota_limit` | 配额或余额用尽 | 充值或更换账号 |+| `provider_capacity_or_rate_limit` | 限流或容量不足 | 稍后重试 || `provider_server_error` | 模型服务端错误(5xx) | 稍后重试 || `provider_network` | 到模型服务的网络故障 | 会自动重试;持续出现时检查执行电脑的网络 || `model_not_found_or_unavailable` | 模型不存在或当前不可用 | 在智能体设置中改选可用模型 |diff --git a/server/pkg/taskfailure/classify.go b/server/pkg/taskfailure/classify.goindex bd2aeafb64..5c60217ce0 100644--- a/server/pkg/taskfailure/classify.go+++ b/server/pkg/taskfailure/classify.go@@ -182,6 +182,7 @@ func Classify(rawError string) Reason {case httpQuotaCodeRe.MatchString(lower),containsAny(lower,"insufficient_balance",+ "insufficient balance","balance is too low","monthly usage limit","usage limit",@@ -681,6 +682,13 @@ var legacyUsageLimit403Reasons = map[string]bool{// reporting.func NormalizeDaemonReason(reason, rawError string) Reason {rawError = WithoutCodebuddyProtocolSummary(rawError)+ // Older daemons treated the billing rejection as a rate limit because+ // they only recognized the numeric status and the structured balance code.+ if reason == ReasonAgentProviderCapacityOrRateLimit.String() &&+ strings.Contains(strings.ToLower(rawError), "insufficient balance") &&+ Classify(rawError) == ReasonAgentProviderQuotaLimit {+ return ReasonAgentProviderQuotaLimit+ }if legacyConcurrentRequestLimitReasons[reason] &&strings.Contains(strings.ToLower(rawError), concurrentRequestLimitWitness) {return ReasonAgentProviderCapacityOrRateLimitdiff --git a/server/pkg/taskfailure/classify_test.go b/server/pkg/taskfailure/classify_test.goindex 91052d9b97..92ccc12007 100644--- a/server/pkg/taskfailure/classify_test.go+++ b/server/pkg/taskfailure/classify_test.go@@ -70,6 +70,7 @@ func TestClassifyRules(t *testing.T) {// 4. Provider quota / billing.{"402", "API Error: 402 Payment Required", ReasonAgentProviderQuotaLimit},{"insufficient_balance", `{"error":{"code":"insufficient_balance"}}`, ReasonAgentProviderQuotaLimit},+ {"provider 429 with insufficient balance", "API Error: Request rejected (429) · [1113][Insufficient balance or no resource package. Please recharge.]", ReasonAgentProviderQuotaLimit},{"balance is too low", "balance is too low to make this request", ReasonAgentProviderQuotaLimit},{"monthly usage limit", "You've hit your org's monthly usage limit", ReasonAgentProviderQuotaLimit},{"usage limit", "Account exceeded the daily usage limit", ReasonAgentProviderQuotaLimit},@@ -670,3 +671,18 @@ func TestClassifyKeepsDeadlineExceededAsProviderNetwork(t *testing.T) {t.Errorf("Classify(provider deadline) = %q, want %q", got, ReasonAgentProviderNetwork)}}++func TestNormalizeDaemonReasonDistinguishesInsufficientBalanceFromRateLimit(t *testing.T) {+ legacy := ReasonAgentProviderCapacityOrRateLimit.String()+ for _, tc := range []struct {+ raw string+ want Reason+ }{+ {"API Error: Request rejected (429) · [1113][Insufficient balance or no resource package. Please recharge.]", ReasonAgentProviderQuotaLimit},+ {"API Error: 429 Too Many Requests", ReasonAgentProviderCapacityOrRateLimit},+ } {+ if got := NormalizeDaemonReason(legacy, tc.raw); got != tc.want {+ t.Errorf("NormalizeDaemonReason(%q, %q) = %q, want %q", legacy, tc.raw, got, tc.want)+ }+ }+}