From 1e1fbb4583e7f2bd90daa747046b4bd2f4378055 Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Tue, 2 Jun 2026 21:46:15 +0700 Subject: [PATCH] fix(discord-gateway): require LLM API key only when AI analysis is enabled --- .../discord-gateway/src/modules/ai-moderation/aiAnalyzer.ts | 4 ++-- services/discord-gateway/src/shared/config/config.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/discord-gateway/src/modules/ai-moderation/aiAnalyzer.ts b/services/discord-gateway/src/modules/ai-moderation/aiAnalyzer.ts index b8bfb48..e90fc9d 100644 --- a/services/discord-gateway/src/modules/ai-moderation/aiAnalyzer.ts +++ b/services/discord-gateway/src/modules/ai-moderation/aiAnalyzer.ts @@ -158,9 +158,9 @@ let lastError: string | null = null; let moderationClient: Client | undefined; // Batch circuit breaker -let consecutiveErrors = 0; +const conversationConsecutiveErrors = new Map(); const MAX_CONSECUTIVE_ERRORS = 5; -let globalCooldownUntil = 0; +const CONVERSATION_CB_COOLDOWN_MS = 60000; // --------------------------------------------------------------------------- // Individual fallback queue — runs PARALLEL to the batch pipeline. diff --git a/services/discord-gateway/src/shared/config/config.ts b/services/discord-gateway/src/shared/config/config.ts index b6a639e..76274e6 100644 --- a/services/discord-gateway/src/shared/config/config.ts +++ b/services/discord-gateway/src/shared/config/config.ts @@ -116,12 +116,12 @@ const configSchema = z .number() .positive() .default(120000), - /** Max concurrent individual-fallback LLM calls (effectively unlimited). */ + /** Max concurrent individual-fallback jobs admitted by the main event loop. */ AI_ANALYSIS_INDIVIDUAL_MAX_CONCURRENT: z.coerce .number() .int() .positive() - .default(1000), + .default(50), /** * How many consecutive individual-fallback errors trigger the individual * circuit breaker (separate from the batch circuit breaker).