Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix: address reviewer comments for auto-disable (use getCachedSettings, immediate disable on permanent bans)

oyi77d5bf0d119973
diff --git a/src/sse/services/auth.ts b/src/sse/services/auth.ts
index b9b6573eaf..97af742ab7 100644
--- a/src/sse/services/auth.ts
+++ b/src/sse/services/auth.ts
@@ -3,6 +3,7 @@ import {
validateApiKey,
updateProviderConnection,
getSettings,
+ getCachedSettings,
} from "@/lib/localDb";
import { getQuotaWindowStatus, isAccountQuotaExhausted } from "@/domain/quotaCache";
import {
@@ -823,17 +824,19 @@ export async function markAccountUnavailable(
// T-AUTODISABLE: If auto-disable setting is enabled and error is permanent/terminal,
// mark account as inactive so it is never retried again.
+ // Uses getCachedSettings() to avoid DB overhead on hot error path.
+ // NOTE: For permanent bans we disable immediately — no threshold needed,
+ // because a permanent ban (403 "Verify your account" / ToS violation) will
+ // NEVER recover, so retrying is pointless regardless of attempt count.
if (result.permanent) {
try {
- const settings = await getSettings();
+ const settings = await getCachedSettings();
const autoDisableEnabled = settings.autoDisableBannedAccounts ?? false;
- const threshold = Number(settings.autoDisableBannedThreshold ?? 3);
- const newBackoff = newBackoffLevel ?? backoffLevel;
- if (autoDisableEnabled && newBackoff >= threshold) {
+ if (autoDisableEnabled) {
await updateProviderConnection(connectionId, { isActive: false });
log.info(
"AUTH",
- `Auto-disabled ${connectionId.slice(0, 8)} — permanent error after ${newBackoff} failures (autoDisableBannedAccounts=true)`
+ `Auto-disabled ${connectionId.slice(0, 8)} — permanent ban detected (autoDisableBannedAccounts=true)`
);
}
} catch (e) {