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).