Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(proxy): isolate the agent read-through singleton between unknown-agent tests

kerry41d6acaa97c0
diff --git a/tests/test_litellm/proxy/common_utils/test_registry_read_through.py b/tests/test_litellm/proxy/common_utils/test_registry_read_through.py
index 6f7c20166c5..ca2ff8bcce1 100644
--- a/tests/test_litellm/proxy/common_utils/test_registry_read_through.py
+++ b/tests/test_litellm/proxy/common_utils/test_registry_read_through.py
@@ -207,7 +207,9 @@ async def test_get_agent_with_read_through_recovers_agent_by_name(clean_agent_re
@pytest.mark.asyncio
-async def test_get_agent_with_read_through_returns_none_for_unknown_agent(clean_agent_registry, monkeypatch):
+async def test_get_agent_with_read_through_returns_none_for_unknown_agent(
+ clean_agent_registry, fresh_agent_read_through, monkeypatch
+):
from unittest.mock import AsyncMock, MagicMock
import litellm.proxy.proxy_server as proxy_server
diff --git a/tests/test_litellm/proxy/conftest.py b/tests/test_litellm/proxy/conftest.py
index 8ef5017a952..49dc8d02bdb 100644
--- a/tests/test_litellm/proxy/conftest.py
+++ b/tests/test_litellm/proxy/conftest.py
@@ -273,3 +273,12 @@ def create_proxy_test_client(
# Initialize proxy
asyncio.run(initialize(config=config_fp, debug=init_options.get("debug", False)))
return TestClient(app)
+
+
+def fresh_agent_read_through(monkeypatch):
+ from litellm.proxy.common_utils import registry_read_through
+
+ read_through = registry_read_through.RegistryReadThrough(resync=registry_read_through._resync_agents)
+ monkeypatch.setattr(registry_read_through, "agent_registry_read_through", read_through)
+ return read_through
diff --git a/tests/test_litellm/proxy/test_route_llm_request.py b/tests/test_litellm/proxy/test_route_llm_request.py
index 6cbbc279748..0b51062dd66 100644
--- a/tests/test_litellm/proxy/test_route_llm_request.py
+++ b/tests/test_litellm/proxy/test_route_llm_request.py
@@ -1282,7 +1282,7 @@ async def test_route_request_routing_group_name_passes_model_gate():
@pytest.mark.asyncio
-async def test_route_request_a2a_agent_miss_does_not_consume_model_read_through(monkeypatch):
+async def test_route_request_a2a_agent_miss_does_not_consume_model_read_through(fresh_agent_read_through, monkeypatch):
from types import SimpleNamespace
from unittest.mock import AsyncMock