fix: propagate simulated flag from response_metadata to tool call events #463
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #462
This PR enables proper logging and tracing of simulated tool calls by propagating the
simulatedflag from AIMessageresponse_metadatato UiPath tool call events.Problem
When LangChain/LangGraph marks tool calls as simulated (via
response_metadata['simulated']in AIMessage), this information was not being propagated to the UiPath tool call events used for logging and tracing. This made it impossible to distinguish simulated tool calls from actual executions.Solution
Updated the
UiPathChatMessagesMapperto:simulatedflag fromresponse_metadatawhen processing AIMessageChunk tool callsmetadatafield ofUiPathConversationToolCallStartEventChanges
src/uipath_langchain/runtime/messages.pytests/runtime/test_simulated_tool_calls.pyTesting
How It Works
When an AIMessage has
response_metadata['simulated'] = True, this flag is:"Tool call {tool_call_id} for {tool_name} is marked as simulated"This enables proper observability for simulated tool calls in scenarios like:
interrupt()