From 41d6acaa97c00ba126a37026fb610a3373d7081a Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 22 Sep 2026 01:34:31 +0000 Subject: [PATCH] test(proxy): isolate the agent read-through singleton between unknown-agent tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../proxy/common_utils/test_registry_read_through.py | 4 +++- tests/test_litellm/proxy/conftest.py | 9 +++++++++ tests/test_litellm/proxy/test_route_llm_request.py | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) 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) + + +@pytest.fixture +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