Skip to content

Commit d67cb25

Browse files
committed
fix: remove dead metadata var, check require_confirmation field, fix legacy hitl payload format
1 parent 2be8c25 commit d67cb25

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

src/uipath_langchain/chat/hitl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ def ask_confirmation():
149149
return tool_args
150150

151151
# Handle both new and legacy payload shapes
152-
if "value" in response and "type" in response:
153-
# Legacy endInterrupt payload
152+
if "value" in response:
153+
# Legacy endInterrupt payload: {"type": ..., "value": {"approved": ..., "input": ...}}
154154
confirmation = response.get("value", response)
155155
else:
156-
# New confirmToolCall payload
156+
# New confirmToolCall payload: {"approved": bool, "input": ...}
157157
confirmation = response
158158

159159
if not confirmation.get("approved", True):

src/uipath_langchain/runtime/messages.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,6 @@ def map_tool_call_to_tool_call_start_event(
544544
require_confirmation: bool | None = None,
545545
input_schema: Any | None = None,
546546
) -> UiPathConversationMessageEvent:
547-
metadata = None
548-
if tool_call["name"] in self.tool_names_requiring_confirmation:
549-
metadata = {"requiresConfirmation": True}
550-
551547
return UiPathConversationMessageEvent(
552548
message_id=message_id,
553549
tool_call=UiPathConversationToolCallEvent(

tests/runtime/test_chat_message_mapper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,7 +2029,7 @@ async def test_confirmation_tool_has_requires_confirmation_metadata(self):
20292029
assert event.tool_call is not None
20302030
assert event.tool_call.start is not None
20312031
assert event.tool_call.start.tool_name == "confirm_tool"
2032-
assert event.tool_call.start.metadata == {"requiresConfirmation": True}
2032+
assert event.tool_call.start.require_confirmation is True
20332033

20342034
@pytest.mark.asyncio
20352035
async def test_normal_tool_has_no_confirmation_metadata(self):
@@ -2060,7 +2060,7 @@ async def test_normal_tool_has_no_confirmation_metadata(self):
20602060
event = tool_start_events[0]
20612061
assert event.tool_call is not None
20622062
assert event.tool_call.start is not None
2063-
assert event.tool_call.start.metadata is None
2063+
assert event.tool_call.start.require_confirmation is None
20642064

20652065
@pytest.mark.asyncio
20662066
async def test_mixed_tools_only_confirmation_has_metadata(self):
@@ -2092,5 +2092,5 @@ async def test_mixed_tools_only_confirmation_has_metadata(self):
20922092
tool_starts[tc.start.tool_name] = tc.start
20932093
assert "normal_tool" in tool_starts
20942094
assert "confirm_tool" in tool_starts
2095-
assert tool_starts["normal_tool"].metadata is None
2096-
assert tool_starts["confirm_tool"].metadata == {"requiresConfirmation": True}
2095+
assert tool_starts["normal_tool"].require_confirmation is None
2096+
assert tool_starts["confirm_tool"].require_confirmation is True

0 commit comments

Comments
 (0)