77from langchain_core .tools import BaseTool
88
99from uipath_langchain .chat .hitl import (
10- ARGS_MODIFIED_MESSAGE ,
1110 CANCELLED_MESSAGE ,
1211 CONVERSATIONAL_APPROVED_TOOL_ARGS ,
1312 ConfirmationResult ,
14- check_tool_confirmation ,
1513 request_approval ,
14+ request_tool_confirmation ,
1615)
1716
1817
@@ -29,33 +28,33 @@ def _make_call(args: dict[str, Any] | None = None) -> ToolCall:
2928
3029
3130class TestCheckToolConfirmation :
32- """Tests for check_tool_confirmation ."""
31+ """Tests for request_tool_confirmation ."""
3332
3433 def test_returns_none_when_no_metadata (self ):
3534 """No metadata → no confirmation needed."""
3635 tool = MockTool ()
3736 call = _make_call ()
38- assert check_tool_confirmation (call , tool ) is None
37+ assert request_tool_confirmation (call , tool ) is None
3938
4039 def test_returns_none_when_flag_not_set (self ):
4140 """Metadata exists but flag is missing → no confirmation needed."""
4241 tool = MockTool (metadata = {"other_key" : True })
4342 call = _make_call ()
44- assert check_tool_confirmation (call , tool ) is None
43+ assert request_tool_confirmation (call , tool ) is None
4544
4645 def test_returns_none_when_flag_false (self ):
4746 """Flag explicitly False → no confirmation needed."""
4847 tool = MockTool (metadata = {"require_conversational_confirmation" : False })
4948 call = _make_call ()
50- assert check_tool_confirmation (call , tool ) is None
49+ assert request_tool_confirmation (call , tool ) is None
5150
5251 @patch ("uipath_langchain.chat.hitl.request_approval" , return_value = None )
5352 def test_cancelled_returns_tool_message (self , mock_approval ):
5453 """User rejects → ConfirmationResult with cancelled ToolMessage and metadata."""
5554 tool = MockTool (metadata = {"require_conversational_confirmation" : True })
5655 call = _make_call ()
5756
58- result = check_tool_confirmation (call , tool )
57+ result = request_tool_confirmation (call , tool )
5958
6059 assert result is not None
6160 assert isinstance (result , ConfirmationResult )
@@ -78,7 +77,7 @@ def test_approved_same_args(self, mock_approval):
7877 tool = MockTool (metadata = {"require_conversational_confirmation" : True })
7978 call = _make_call ({"query" : "test" })
8079
81- result = check_tool_confirmation (call , tool )
80+ result = request_tool_confirmation (call , tool )
8281
8382 assert result is not None
8483 assert result .cancelled is None
@@ -94,7 +93,7 @@ def test_approved_modified_args(self, mock_approval):
9493 tool = MockTool (metadata = {"require_conversational_confirmation" : True })
9594 call = _make_call ({"query" : "original" })
9695
97- result = check_tool_confirmation (call , tool )
96+ result = request_tool_confirmation (call , tool )
9897
9998 assert result is not None
10099 assert result .cancelled is None
@@ -122,7 +121,7 @@ def test_annotate_sets_metadata(self):
122121 assert msg .content == "result"
123122
124123 def test_annotate_wraps_content_when_modified (self ):
125- """annotate_result wraps content when args were modified."""
124+ """annotate_result wraps content with structured meta when args were modified."""
126125 confirmation = ConfirmationResult (
127126 cancelled = None , args_modified = True , approved_args = {"query" : "edited" }
128127 )
@@ -134,8 +133,12 @@ def test_annotate_wraps_content_when_modified(self):
134133 assert msg .response_metadata [CONVERSATIONAL_APPROVED_TOOL_ARGS ] == {
135134 "query" : "edited"
136135 }
137- assert ARGS_MODIFIED_MESSAGE in msg .content
138- assert "result" in msg .content
136+ import json
137+
138+ wrapped = json .loads (msg .content )
139+ assert wrapped ["meta" ]["args_modified_by_user" ] is True
140+ assert wrapped ["meta" ]["executed_args" ] == {"query" : "edited" }
141+ assert wrapped ["result" ] == "result"
139142
140143
141144class TestRequestApprovalTruthiness :
0 commit comments