~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
test: regression for full ProcessingLLMWrapper(RateLimitedLLMWrapper(ChatOllama)) close chain (#3933)
LearningCircuit0a05db19ee9e
diff --git a/tests/utilities/test_close_base_llm.py b/tests/utilities/test_close_base_llm.pyindex 08eed37768..a1c5718c82 100644--- a/tests/utilities/test_close_base_llm.py+++ b/tests/utilities/test_close_base_llm.py@@ -399,3 +399,47 @@ class TestCloseBaseLLMRealLangchain:# the shared cached httpx clients must remain open.assert sync_httpx.is_closed is Falseassert async_httpx.is_closed is False++ def test_full_wrapper_stack_via_rate_limited_closes_both_clients(self):+ """Regression: when rate limiting is enabled, the production+ wrapper stack is ``ProcessingLLMWrapper(RateLimitedLLMWrapper(+ ChatOllama))`` and ``safe_close`` has to recurse through *both*+ wrapper layers to reach ``_close_base_llm``'s introspection.++ The other ``Real Langchain`` tests only exercise the+ ``ProcessingLLMWrapper`` layer. This one specifically guards+ the ``RateLimitedLLMWrapper.close → _close_base_llm`` hop so a+ future change to that wrapper's ``close()`` doesn't silently+ break the chain and let the #3816 leak come back.+ """+ from langchain_ollama import ChatOllama++ from local_deep_research.config.llm_config import (+ wrap_llm_without_think_tags,+ )+ from local_deep_research.utilities.resource_utils import safe_close+ from local_deep_research.web_search_engines.rate_limiting.llm import (+ create_rate_limited_llm_wrapper,+ )++ llm = ChatOllama(model="test", base_url="http://localhost:1")+ sync_httpx = llm._client._client+ async_httpx = llm._async_client._client+ assert sync_httpx.is_closed is False+ assert async_httpx.is_closed is False++ # Build the stack manually — wrap_llm_without_think_tags only+ # adds the rate-limited layer when ``rate_limiting.llm_enabled``+ # is True in the settings, and we want this test to hold+ # regardless of that setting.+ rate_limited = create_rate_limited_llm_wrapper(llm, provider="ollama")+ full = wrap_llm_without_think_tags(rate_limited, settings_snapshot={})++ safe_close(full, "regression test full wrapper stack")++ # Recursion: safe_close(Processing) → Processing.close →+ # _close_base_llm(RateLimited) → hasattr(type, "close") fires →+ # RateLimited.close() → _close_base_llm(ChatOllama) →+ # introspection closes both inner httpx clients.+ assert sync_httpx.is_closed is True+ assert async_httpx.is_closed is True