@@ -753,31 +753,30 @@ def test_instrument_set_when_settings_returned(self, mock_settings):
753753 sentinel = MagicMock (name = "InstrumentationSettings" )
754754 mock_settings .return_value = sentinel
755755 hook = self ._hook ()
756- with patch .object (hook , "get_conn " , return_value = TestModel ()):
757- agent = hook .create_agent (instructions = "hi" )
756+ with patch .object (hook , "get_model " , return_value = TestModel ()):
757+ agent = hook .create_agent (AgentRunRequest ( prompt = "test" , instructions = "hi" ) )
758758
759759 assert agent .instrument is sentinel
760760
761761 @patch ("airflow.providers.common.ai.hooks.pydantic_ai.genai_instrumentation_settings" )
762762 def test_no_instrument_when_settings_none (self , mock_settings ):
763763 mock_settings .return_value = None
764764 hook = self ._hook ()
765- with patch .object (hook , "get_conn " , return_value = TestModel ()):
766- agent = hook .create_agent (instructions = "hi" )
765+ with patch .object (hook , "get_model " , return_value = TestModel ()):
766+ agent = hook .create_agent (AgentRunRequest ( prompt = "test" , instructions = "hi" ) )
767767
768768 mock_settings .assert_called_once ()
769769 assert agent .instrument is None
770770
771771 @patch ("airflow.providers.common.ai.hooks.pydantic_ai.Agent" , autospec = True )
772772 @patch ("airflow.providers.common.ai.hooks.pydantic_ai.genai_instrumentation_settings" )
773- @patch ("airflow.providers.common.ai.hooks.pydantic_ai.infer_model" , autospec = True )
774- def test_caller_instrument_short_circuits (self , mock_infer_model , mock_settings , mock_agent_cls ):
775- """A caller that passes its own ``instrument`` wins; we don't override it."""
776- mock_infer_model .return_value = MagicMock (spec = Model )
773+ def test_caller_instrument_short_circuits (self , mock_settings , mock_agent_cls ):
774+ """A caller that passes its own ``instrument`` via agent_params wins; we don't override it."""
777775 hook = self ._hook ()
778- conn = Connection (conn_id = "test_conn" , conn_type = "pydanticai" )
779- with patch .object (hook , "get_connection" , return_value = conn ):
780- hook .create_agent (instructions = "hi" , instrument = False )
776+ with patch .object (hook , "get_model" , return_value = TestModel ()):
777+ hook .create_agent (
778+ AgentRunRequest (prompt = "test" , instructions = "hi" , agent_params = {"instrument" : False })
779+ )
781780
782781 mock_settings .assert_not_called ()
783782
0 commit comments