@@ -281,6 +281,56 @@ def test_deepseek_defaults_to_openai(self):
281281 agent = _make_openai_agent ()
282282 assert agent ._detect_provider_from_model ("deepseek-chat" ) == "openai"
283283
284+ def test_unknown_prefix_falls_back_to_openai (self ):
285+ agent = _make_openai_agent ()
286+ assert agent ._detect_provider_from_model ("ollama/llama3" ) == "openai"
287+ assert agent ._detect_provider_from_model ("anthropic/claude-3" ) == "openai"
288+
289+
290+ class TestResolveProviderAndModel :
291+ """``_resolve_provider_and_model`` returns ``(provider, model)``: it strips
292+ recognised provider aliases and defaults unknown prefixes to openai."""
293+
294+ def test_gemini_alias_maps_to_google (self ):
295+ agent = _make_openai_agent ()
296+ assert agent ._resolve_provider_and_model ("gemini/gemini-2.5-flash" ) == (
297+ "google" ,
298+ "gemini-2.5-flash" ,
299+ )
300+
301+ def test_google_alias_maps_to_google (self ):
302+ agent = _make_openai_agent ()
303+ assert agent ._resolve_provider_and_model ("google/gemini-2.0-flash" ) == (
304+ "google" ,
305+ "gemini-2.0-flash" ,
306+ )
307+
308+ def test_openai_alias_maps_to_openai (self ):
309+ agent = _make_openai_agent ()
310+ assert agent ._resolve_provider_and_model ("openai/gpt-4o" ) == ("openai" , "gpt-4o" )
311+
312+ def test_gpt_alias_maps_to_openai (self ):
313+ agent = _make_openai_agent ()
314+ assert agent ._resolve_provider_and_model ("gpt/gpt-4o" ) == ("openai" , "gpt-4o" )
315+
316+ def test_unknown_prefix_defaults_to_openai_and_keeps_full_model (self ):
317+ agent = _make_openai_agent ()
318+ assert agent ._resolve_provider_and_model ("meta-llama/Llama-3-70b" ) == (
319+ "openai" ,
320+ "meta-llama/Llama-3-70b" ,
321+ )
322+
323+ def test_bare_unknown_model_defaults_to_openai (self ):
324+ agent = _make_openai_agent ()
325+ assert agent ._resolve_provider_and_model ("llama3:70b" ) == ("openai" , "llama3:70b" )
326+
327+ def test_use_vertex_ai_forces_google (self ):
328+ agent = _make_openai_agent ()
329+ assert agent ._resolve_provider_and_model ("llama3:70b" , use_vertex_ai = True ) == (
330+ "google" ,
331+ "llama3:70b" ,
332+ )
333+
284334
285335class TestValidateOutputType :
286336 def test_valid_text_type_does_not_raise (self ):
@@ -1955,6 +2005,41 @@ def test_unknown_model_without_provider_auto_detects_openai(self):
19552005 agent = Agent (model = "llama3:70b" , reasoning_config = None )
19562006 assert agent .provider == "openai"
19572007
2008+ def test_gemini_slash_prefix_maps_to_google_provider (self ):
2009+ """The ``gemini/`` alias must resolve to the ``google`` provider."""
2010+ with patch .object (Agent , "_create_client" , return_value = MagicMock ()):
2011+ agent = Agent (model = "gemini/gemini-2.5-flash" , reasoning_config = None )
2012+ assert agent .provider == "google"
2013+ assert agent .model == "gemini-2.5-flash"
2014+
2015+ def test_gpt_slash_prefix_maps_to_openai_provider (self ):
2016+ """The ``gpt/`` alias must resolve to the ``openai`` provider."""
2017+ with patch .object (Agent , "_create_client" , return_value = MagicMock ()):
2018+ agent = Agent (model = "gpt/gpt-4o" , reasoning_config = None )
2019+ assert agent .provider == "openai"
2020+ assert agent .model == "gpt-4o"
2021+
2022+ def test_unknown_prefix_resolves_to_openai_and_keeps_full_model (self ):
2023+ """An unrecognised prefix must default to openai, not google, and keep
2024+ the full model string (it may be an OpenAI-compatible / HF-style name)."""
2025+ with patch .object (Agent , "_create_client" , return_value = MagicMock ()):
2026+ agent = Agent (model = "meta-llama/Llama-3-70b" , reasoning_config = None )
2027+ assert agent .provider == "openai"
2028+ assert agent .model == "meta-llama/Llama-3-70b"
2029+
2030+ def test_anthropic_prefix_resolves_to_openai (self ):
2031+ """Claude via an OpenAI-compatible endpoint should not select google."""
2032+ with patch .object (Agent , "_create_client" , return_value = MagicMock ()):
2033+ agent = Agent (model = "anthropic/claude-3" , reasoning_config = None )
2034+ assert agent .provider == "openai"
2035+ assert agent .model == "anthropic/claude-3"
2036+
2037+ def test_ollama_prefix_resolves_to_openai (self ):
2038+ with patch .object (Agent , "_create_client" , return_value = MagicMock ()):
2039+ agent = Agent (model = "ollama/llama3" , reasoning_config = None )
2040+ assert agent .provider == "openai"
2041+ assert agent .model == "ollama/llama3"
2042+
19582043 # ── reasoning config normalization ────────────────────────────────────
19592044
19602045 def test_default_sentinel_produces_medium_effort (self ):
0 commit comments