From ad2ed3c4195eaf169049992c2b06af3a58883583 Mon Sep 17 00:00:00 2001 From: Joshua Valluru <326636767+joshua-berri@users.noreply.github.com> Date: Sat, 31 Oct 2026 16:50:08 -0700 Subject: [PATCH] test: verify switchyard preserves context overflow errors --- .../test_switchyard_router.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/unit/router_strategy/switchyard_router/test_switchyard_router.py b/tests/unit/router_strategy/switchyard_router/test_switchyard_router.py index ccc00684592..9cc51689cad 100644 --- a/tests/unit/router_strategy/switchyard_router/test_switchyard_router.py +++ b/tests/unit/router_strategy/switchyard_router/test_switchyard_router.py @@ -347,18 +347,14 @@ async def test_disabling_fallback_preserves_selected_provider_failure() -> None: @pytest.mark.asyncio -async def test_escalation_context_overflow_executes_capable_without_judge() -> None: - answer: Final = response("strong", "fits") - provider: Final = ScriptedProvider( - { - "fast": ContextWindowExceededError("too large", "fast", "fake"), - "strong": answer, - } - ) +async def test_escalation_preserves_context_overflow_without_calling_another_provider() -> None: + error: Final = ContextWindowExceededError("too large", "fast", "fake") + provider: Final = ScriptedProvider({"fast": error}) router: Final = SwitchyardAutoRouter(classifier_config("escalation", escalation={"confirmations": 1})) - actual: Final = await router.execute({"messages": [{"role": "user", "content": "hello"}]}, provider) - assert actual is answer - assert tuple(model for model, _ in provider.calls) == ("fast", "strong") + with pytest.raises(ContextWindowExceededError) as raised: + await router.execute({"messages": [{"role": "user", "content": "hello"}]}, provider) + assert raised.value is error + assert tuple(model for model, _ in provider.calls) == ("fast",) @pytest.mark.asyncio