修复扣费失败无条件终止语音会话:仅余额不足时才终止

原逻辑 if True: 导致数据库瞬时错误也终止整个语音事件循环,
AI 回复被中途截断。改为仅当 reason == insufficient_tokens 时
才终止,其他扣费错误(如 DB 超时)不中断会话。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
wsb1224 2026-06-10 15:42:31 +08:00
parent d52073adb4
commit ec876e1362

View File

@ -1283,7 +1283,7 @@ async def receive_events_loop(
except Exception:
pass
# 扣费失败时终止事件循环(余额不够最低消费也要停)
if True:
if charge_result.get("reason") == "insufficient_tokens":
logger.warning(
f"[VOICE_TOKEN_EXHAUSTED] user_id={user_id} mode={charge_mode} "
f"remaining={remaining}, breaking event loop and closing"