@@ -1199,6 +1199,7 @@ async def test_non_streaming_async_returns_tool_calls_when_text_also_present():
11991199 response = _build_response_with_text_and_tool_calls ()
12001200
12011201 async def _ret (* args , ** kwargs ):
1202+ """Return the pre-built mock response."""
12021203 return response
12031204
12041205 with patch ("crewai.llm.litellm.acompletion" , side_effect = _ret ):
@@ -1214,6 +1215,35 @@ def test_validate_call_params_handles_introspection_error():
12141215 llm = LLM (model = "custom/unsupported-model" , is_litellm = True , response_format = {"type" : "json_object" })
12151216
12161217 with patch ("crewai.llm.supports_response_schema" , side_effect = Exception ("Introspection error" )):
1217- # Should not raise exception
1218+ # Should not raise exception — permissive fallback applies
12181219 llm ._validate_call_params ()
12191220
1221+
1222+ def test_validate_call_params_raises_for_confirmed_unsupported_model ():
1223+ """Verify _validate_call_params still raises ValueError when introspection confirms no support.
1224+
1225+ This ensures the validation path is not silently skipped — only introspection
1226+ *errors* are swallowed; a clear ``False`` return still produces a ValueError.
1227+ """
1228+ llm = LLM (model = "my-provider/my-model" , is_litellm = True , response_format = {"type" : "json_object" })
1229+
1230+ with patch ("crewai.llm.supports_response_schema" , return_value = False ):
1231+ with pytest .raises (ValueError , match = "does not support response_format" ):
1232+ llm ._validate_call_params ()
1233+
1234+
1235+ def test_validate_call_params_skips_check_when_no_response_format ():
1236+ """Verify _validate_call_params is a no-op when response_format is not set.
1237+
1238+ This covers scenarios where only ``reasoning_effort`` or other parameters
1239+ are configured: the method must return immediately so those parameters are
1240+ forwarded to the provider without interference.
1241+ """
1242+ llm = LLM (model = "gpt-4o" , is_litellm = True , reasoning_effort = "medium" )
1243+
1244+ # If supports_response_schema were called, patching it to raise would surface the bug
1245+ with patch ("crewai.llm.supports_response_schema" , side_effect = Exception ("Should not be called" )):
1246+ # No exception — response_format is None so introspection is never invoked
1247+ llm ._validate_call_params ()
1248+
1249+
0 commit comments