fix(llm): 识别钱包型欠费 insufficient_funds,欠费不再落回未完成检测
This commit is contained in:
@@ -34,6 +34,11 @@ public final class LlmBalanceGuard {
|
||||
"insufficient_user_quota",
|
||||
"insufficient_quota",
|
||||
"insufficient balance",
|
||||
// 2026-11-11 现网:钱包型欠费走 insufficient_funds + "wallet balance insufficient",
|
||||
// 与上面两条的拼写与词序都不同("balance insufficient" 里没有连续的 "insufficient balance"),
|
||||
// 漏掉这两个锚点,欠费就会一路落回"未完成检测/上游不可用",用户根本看不到"欠费"。
|
||||
"insufficient_funds",
|
||||
"wallet balance insufficient",
|
||||
"预扣费额度失败",
|
||||
"额度不足",
|
||||
"余额不足",
|
||||
|
||||
@@ -30,6 +30,22 @@ class LlmBalanceGuardTest {
|
||||
assertThat(LlmBalanceGuard.isQuotaExhausted(wrapped)).isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 2026-11-11 现网原文(A 机 java-server,12 小时 3737 次,界面仍显示"未完成检测"):
|
||||
* 这一家的钱包欠费用的是 {@code insufficient_funds} 与 {@code wallet balance insufficient},
|
||||
* 与上面那条 403 的 {@code insufficient_user_quota} / {@code insufficient balance} 拼写与词序都不同,
|
||||
* 旧词表一条都命中不了 ⇒ 用户完全看不到"欠费"这两个字。
|
||||
*/
|
||||
@Test
|
||||
void detectsObservedWalletBalanceBody() {
|
||||
IllegalStateException observed = new IllegalStateException(
|
||||
"LLM http 402: {\"error\":{\"code\":\"insufficient_funds\",\"message\":\"wallet balance "
|
||||
+ "insufficient for chat gm-3.5-flash-lite (本次需预留约 ⚡0.02)\","
|
||||
+ "\"type\":\"insufficient_funds\"}}");
|
||||
|
||||
assertThat(LlmBalanceGuard.isQuotaExhausted(observed)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void transientFailuresAreNotQuotaExhaustion() {
|
||||
assertThat(LlmBalanceGuard.isQuotaExhausted(new IllegalStateException("LLM http 502: bad gateway"))).isFalse();
|
||||
|
||||
Reference in New Issue
Block a user