fix(llm): 识别钱包型欠费 insufficient_funds,欠费不再落回未完成检测

This commit is contained in:
2026-11-11 18:15:41 +08:00
parent 7a69210967
commit 691b29da7e
2 changed files with 21 additions and 0 deletions
@@ -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();