惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog
IT之家
IT之家
博客园 - 聂微东
The Cloudflare Blog
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
H
Help Net Security
博客园 - 叶小钗
V
V2EX
WordPress大学
WordPress大学
J
Java Code Geeks
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
C
Check Point Blog
B
Blog
D
DataBreaches.Net
美团技术团队
罗磊的独立博客

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
Preserve xAI usage limit errors in local TUI (#86614) · o...
fuller-stack · 2026-05-27 · via Recent Commits to openclaw:main

@@ -5,6 +5,7 @@ import {

55

extractLeadingHttpStatus,

66

formatRawAssistantErrorForUi,

77

isGenericProviderInternalError,

8+

parseApiErrorInfo,

89

} from "../../shared/assistant-error-format.js";

910

import {

1011

normalizeLowercaseStringOrEmpty,

@@ -675,11 +676,10 @@ function classifyFailoverClassificationFromHttpStatus(

675676

return toReasonClassification(classify402Message(message));

676677

}

677678

if (status === 429) {

678-

if (

679-

message &&

680-

(isProvider(provider, "moonshot") || isProvider(provider, "kimi")) &&

681-

isBillingErrorMessage(message)

682-

) {

679+

if (messageReason === "billing" && !isAmbiguousGeneric429BalanceMessage(message ?? "")) {

680+

return toReasonClassification("billing");

681+

}

682+

if (message && isBilling429MessageForProvider(message, provider)) {

683683

return toReasonClassification("billing");

684684

}

685685

return toReasonClassification("rate_limit");

@@ -797,6 +797,39 @@ function isProvider(provider: string | undefined, match: string): boolean {

797797

return Boolean(normalized && normalized.includes(match));

798798

}

799799800+

function hasProviderBilling429Override(provider: string | undefined): boolean {

801+

return (

802+

isProvider(provider, "xai") || isProvider(provider, "moonshot") || isProvider(provider, "kimi")

803+

);

804+

}

805+806+

function hasStructuredBilling429Signal(raw: string): boolean {

807+

if (hasBillingApiErrorType(raw)) {

808+

return true;

809+

}

810+

const leadingStatus = extractLeadingHttpStatus(raw.trim());

811+

return Boolean(leadingStatus?.rest && hasBillingApiErrorType(leadingStatus.rest));

812+

}

813+814+

function hasBillingApiErrorType(raw: string): boolean {

815+

const type = normalizeOptionalLowercaseString(parseApiErrorInfo(raw)?.type);

816+

if (!type) {

817+

return false;

818+

}

819+

return isBillingErrorMessage(type) || isBillingErrorMessage(type.replaceAll("_", " "));

820+

}

821+822+

function isAmbiguousGeneric429BalanceMessage(raw: string): boolean {

823+

return /\binsufficient\s+account\s+balance\b/i.test(raw) && !hasStructuredBilling429Signal(raw);

824+

}

825+826+

function isBilling429MessageForProvider(raw: string, provider: string | undefined): boolean {

827+

if (!isBillingErrorMessage(raw)) {

828+

return false;

829+

}

830+

return hasProviderBilling429Override(provider) || !isAmbiguousGeneric429BalanceMessage(raw);

831+

}

832+800833

// pi-ai providers throw `Error("An unknown error occurred")` provider-agnostically

801834

// (anthropic, google, vertex, openai-completions, mistral, bedrock, etc.) when a

802835

// stream ends with stopReason === "aborted" | "error" without specific info. Treat

@@ -861,6 +894,10 @@ function classifyFailoverClassificationFromMessage(

861894

) {

862895

return toReasonClassification("billing");

863896

}

897+

const leadingStatus = extractLeadingHttpStatus(raw.trim());

898+

if (leadingStatus?.code !== 429 && isBillingErrorMessage(raw)) {

899+

return toReasonClassification("billing");

900+

}

864901

if (isPeriodicUsageLimitErrorMessage(raw)) {

865902

return toReasonClassification(isBillingErrorMessage(raw) ? "billing" : "rate_limit");

866903

}

@@ -888,12 +925,9 @@ function classifyFailoverClassificationFromMessage(

888925

if (isGenericProviderInternalError(raw)) {

889926

return toReasonClassification("timeout");

890927

}

891-

// Billing and auth classifiers run before the broad isJsonApiInternalServerError

892-

// check so that provider errors like {"type":"api_error","message":"insufficient

893-

// balance"} are correctly classified as "billing"/"auth" rather than "timeout".

894-

if (isBillingErrorMessage(raw)) {

895-

return toReasonClassification("billing");

896-

}

928+

// Auth classifiers run before the broad isJsonApiInternalServerError check so that

929+

// provider errors like {"type":"api_error","message":"invalid api key"} are

930+

// correctly classified as "auth" rather than "timeout".

897931

const oauthRefreshFailure = classifyOAuthRefreshFailure(raw);

898932

if (oauthRefreshFailure?.reason) {

899933

return toReasonClassification("auth_permanent");

@@ -1181,6 +1215,16 @@ export function formatAssistantErrorText(

11811215

return `LLM request rejected: ${invalidRequest[1]}`;

11821216

}

118312171218+

if (

1219+

isOpenRouterKeyLimitExceededError(raw, opts?.provider) ||

1220+

isOpenRouterKeyBudgetLimitExceededError(raw, opts?.provider)

1221+

) {

1222+

return formatBillingErrorMessage(opts?.provider, opts?.model ?? msg.model);

1223+

}

1224+

if (isBilling429MessageForProvider(raw, opts?.provider)) {

1225+

return formatBillingErrorMessage(opts?.provider, opts?.model ?? msg.model);

1226+

}

1227+11841228

const transientCopy = formatRateLimitOrOverloadedErrorCopy(raw);

11851229

if (transientCopy) {

11861230

return transientCopy;