@@ -1996,12 +1996,26 @@ async def test_pii_masked_response_full_flow(self):
19961996 assert result [- 1 ].end is not None
19971997
19981998
1999+ def _require_confirmation_field_available () -> bool :
2000+ """Return True if the installed uipath-core exposes the require_confirmation field."""
2001+ try :
2002+ from uipath .core .chat .tool import (
2003+ UiPathConversationToolCallStartEvent ,
2004+ )
2005+
2006+ return hasattr (UiPathConversationToolCallStartEvent , "require_confirmation" )
2007+ except Exception :
2008+ return False
2009+
2010+
19992011class TestConfirmationToolDeferral :
20002012 """Tests for deferring startToolCall events for confirmation tools."""
20012013
20022014 @pytest .mark .asyncio
20032015 async def test_confirmation_tool_has_requires_confirmation_metadata (self ):
20042016 """startToolCall for confirmation tools includes requiresConfirmation in metadata."""
2017+ if not _require_confirmation_field_available ():
2018+ pytest .skip ("requires uipath-core>=0.5.12 with require_confirmation field" )
20052019 storage = create_mock_storage ()
20062020 storage .get_value .return_value = {}
20072021 mapper = UiPathChatMessagesMapper ("test-runtime" , storage )
@@ -2029,11 +2043,13 @@ async def test_confirmation_tool_has_requires_confirmation_metadata(self):
20292043 assert event .tool_call is not None
20302044 assert event .tool_call .start is not None
20312045 assert event .tool_call .start .tool_name == "confirm_tool"
2032- assert event .tool_call .start .require_confirmation is True
2046+ assert event .tool_call .start .require_confirmation is True # type: ignore[attr-defined]
20332047
20342048 @pytest .mark .asyncio
20352049 async def test_normal_tool_has_no_confirmation_metadata (self ):
20362050 """startToolCall for normal tools has no metadata."""
2051+ if not _require_confirmation_field_available ():
2052+ pytest .skip ("requires uipath-core>=0.5.12 with require_confirmation field" )
20372053 storage = create_mock_storage ()
20382054 storage .get_value .return_value = {}
20392055 mapper = UiPathChatMessagesMapper ("test-runtime" , storage )
@@ -2060,11 +2076,13 @@ async def test_normal_tool_has_no_confirmation_metadata(self):
20602076 event = tool_start_events [0 ]
20612077 assert event .tool_call is not None
20622078 assert event .tool_call .start is not None
2063- assert event .tool_call .start .require_confirmation is None
2079+ assert event .tool_call .start .require_confirmation is None # type: ignore[attr-defined]
20642080
20652081 @pytest .mark .asyncio
20662082 async def test_mixed_tools_only_confirmation_has_metadata (self ):
20672083 """In mixed tool calls, only confirmation tools get the metadata flag."""
2084+ if not _require_confirmation_field_available ():
2085+ pytest .skip ("requires uipath-core>=0.5.12 with require_confirmation field" )
20682086 storage = create_mock_storage ()
20692087 storage .get_value .return_value = {}
20702088 mapper = UiPathChatMessagesMapper ("test-runtime" , storage )
@@ -2092,5 +2110,5 @@ async def test_mixed_tools_only_confirmation_has_metadata(self):
20922110 tool_starts [tc .start .tool_name ] = tc .start
20932111 assert "normal_tool" in tool_starts
20942112 assert "confirm_tool" in tool_starts
2095- assert tool_starts ["normal_tool" ].require_confirmation is None
2096- assert tool_starts ["confirm_tool" ].require_confirmation is True
2113+ assert tool_starts ["normal_tool" ].require_confirmation is None # type: ignore[attr-defined]
2114+ assert tool_starts ["confirm_tool" ].require_confirmation is True # type: ignore[attr-defined]
0 commit comments