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>
This commit is contained in:
kerry 2026-09-22 01:34:31 +00:00
parent ee73e6391e
commit 41d6acaa97
3 changed files with 13 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -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