Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

feat: add ENABLE_RATE_LIMITING flag to allow rate limiting in CI

LearningCircuit1abddab5c218
diff --git a/src/local_deep_research/settings/env_registry.py b/src/local_deep_research/settings/env_registry.py
index 6accc35a3c..9e2b82369a 100644
--- a/src/local_deep_research/settings/env_registry.py
+++ b/src/local_deep_research/settings/env_registry.py
@@ -71,6 +71,26 @@ def is_github_actions() -> bool:
)
+def is_rate_limiting_enabled() -> bool:
+ """
+ Check if rate limiting should be enabled.
+
+ Returns:
+ True if rate limiting should be enabled, False otherwise
+
+ Logic:
+ - If ENABLE_RATE_LIMITING=true, always enable (even in CI)
+ - If in CI without the flag, disable
+ - If not in CI, enable
+ """
+ import os
+
+ enable_flag = os.environ.get("ENABLE_RATE_LIMITING", "").lower()
+ if enable_flag == "true":
+ return True
+ return not is_ci_environment()
+
+
# Export the registry and convenience functions
__all__ = [
"registry",
@@ -79,4 +99,5 @@ __all__ = [
"use_fallback_llm",
"is_ci_environment",
"is_github_actions",
+ "is_rate_limiting_enabled",
]
diff --git a/src/local_deep_research/web/utils/rate_limiter.py b/src/local_deep_research/web/utils/rate_limiter.py
index e6ea30a1a6..bf055af693 100644
--- a/src/local_deep_research/web/utils/rate_limiter.py
+++ b/src/local_deep_research/web/utils/rate_limiter.py
@@ -7,7 +7,7 @@ from flask import request
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address
-from ...settings.env_registry import is_ci_environment
+from ...settings.env_registry import is_rate_limiting_enabled
def get_client_ip():
@@ -33,13 +33,14 @@ def get_client_ip():
# Global limiter instance - will be initialized in app_factory
-# Rate limiting is disabled in CI via enabled callable
+# Rate limiting is disabled in CI unless ENABLE_RATE_LIMITING=true
+# This allows the rate limiting test to run with rate limiting enabled
limiter = Limiter(
key_func=get_client_ip,
default_limits=["200 per day", "50 per hour"],
storage_uri="memory://",
headers_enabled=True,
- enabled=lambda: not is_ci_environment(),
+ enabled=is_rate_limiting_enabled,
)
diff --git a/tests/ui_tests/test_rate_limiting_settings.js b/tests/ui_tests/test_rate_limiting_settings.js
index b108efddae..fa54afcf19 100644
--- a/tests/ui_tests/test_rate_limiting_settings.js
+++ b/tests/ui_tests/test_rate_limiting_settings.js
@@ -14,6 +14,14 @@ const puppeteer = require('puppeteer');
const { getPuppeteerLaunchOptions } = require('./puppeteer_config');
async function testRateLimiting() {
+ // Skip this test in CI unless ENABLE_RATE_LIMITING=true
+ // Rate limiting is disabled in CI by default, so this test would fail
+ if (process.env.CI && process.env.ENABLE_RATE_LIMITING !== 'true') {
+ console.log('⚠️ Skipping rate limiting test in CI (requires ENABLE_RATE_LIMITING=true)');
+ console.log('ℹ️ This test needs rate limiting enabled, but CI disables it by default');
+ return true;
+ }
+
const browser = await puppeteer.launch(getPuppeteerLaunchOptions());
const page = await browser.newPage();
const baseUrl = 'http://127.0.0.1:5000';