diff --git a/agent/agent_init.py b/agent/agent_init.py index fe6a2ca1fac..b1dc211dca4 100644 --- a/agent/agent_init.py +++ b/agent/agent_init.py @@ -2023,7 +2023,6 @@ def init_agent( _active_base_url = _normalize_route_base_url(_active_route_url) _route_mismatch = bool( _configured_base_url - and _active_base_url and _configured_base_url != _active_base_url ) if not _configured_base_url: diff --git a/tests/run_agent/test_switch_model_context.py b/tests/run_agent/test_switch_model_context.py index 6528c5c39b7..712fabbf7b5 100644 --- a/tests/run_agent/test_switch_model_context.py +++ b/tests/run_agent/test_switch_model_context.py @@ -248,6 +248,32 @@ def test_direct_start_same_model_on_different_route_drops_context_override(): assert agent.context_compressor.context_length == 272_000 +def test_direct_start_drops_context_when_configured_route_has_no_active_url(): + """A configured endpoint cannot own a runtime whose endpoint is unknown.""" + cfg = { + "model": { + "default": "shared-model", + "provider": "custom", + "base_url": "https://large.example/v1", + "context_length": 1_048_576, + } + } + routed_client = MagicMock(api_key="fake-test-token", base_url="") + + with patch( + "agent.auxiliary_client.resolve_provider_client", + return_value=(routed_client, "shared-model"), + ): + agent = _make_direct_start_agent( + cfg, + model="shared-model", + provider="custom", + base_url="", + ) + + assert agent.context_compressor.config_context_length is None + + def test_direct_start_preserves_context_for_bare_aggregator_model(): """Aggregator normalization must compare both sides, not rewrite one side.""" cfg = {