From 47156451457dbeb2ff657afb00d9d226b62cccbe Mon Sep 17 00:00:00 2001 From: Roo Code Date: Mon, 22 Dec 2025 13:35:55 +0000 Subject: [PATCH] fix: use task stored API config as fallback for rate limit When provider state is unavailable (state is undefined/null), fall back to the task's stored apiConfiguration for rate limiting instead of defaulting to 0. This prevents rate limiting from being silently disabled in edge cases where getState() fails or provider reference is temporarily lost. Changes: - Line 3643 (attemptApiRequest): Use (apiConfiguration ?? this.apiConfiguration) - Line 3974 (backoffAndAnnounce): Use (state?.apiConfiguration ?? this.apiConfiguration) Both locations now follow the same pattern: 1. Prefer the most up-to-date config from provider state 2. Fall back to task's stored config if state unavailable 3. Only default to 0 if neither source has a config --- src/core/task/Task.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 9e41d5c4dd..5fcfde37ef 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -4242,7 +4242,7 @@ export class Task extends EventEmitter implements TaskLike { // Respect provider rate limit window let rateLimitDelay = 0 - const rateLimit = state?.apiConfiguration?.rateLimitSeconds || 0 + const rateLimit = (state?.apiConfiguration ?? this.apiConfiguration)?.rateLimitSeconds || 0 if (Task.lastGlobalApiRequestTime && rateLimit > 0) { const elapsed = performance.now() - Task.lastGlobalApiRequestTime rateLimitDelay = Math.ceil(Math.min(rateLimit, Math.max(0, rateLimit * 1000 - elapsed) / 1000))