Skip to content

Conversation

@mjnovice
Copy link

Summary

Fixes #462

This PR enables proper logging and tracing of simulated tool calls by propagating the simulated flag from AIMessage response_metadata to 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 UiPathChatMessagesMapper to:

  1. Extract the simulated flag from response_metadata when processing AIMessageChunk tool calls
  2. Add it to the metadata field of UiPathConversationToolCallStartEvent
  3. Log a message when a tool call is marked as simulated for better visibility

Changes

  • Modified: src/uipath_langchain/runtime/messages.py
    • Added logic to extract and propagate the simulated flag
    • Added logging when tool calls are marked as simulated
  • Added: tests/runtime/test_simulated_tool_calls.py
    • Comprehensive test coverage for simulated tool call handling

Testing

  • ✅ 3 new tests for simulated tool call handling
  • ✅ All 37 existing runtime tests continue to pass

How It Works

When an AIMessage has response_metadata['simulated'] = True, this flag is:

  1. Extracted during event mapping
  2. Added to the tool call start event's metadata
  3. Logged with: "Tool call {tool_call_id} for {tool_name} is marked as simulated"
  4. Available in traces through the event metadata

This enables proper observability for simulated tool calls in scenarios like:

  • Testing and mocking
  • Human-in-the-loop workflows with interrupt()
  • LLM provider-marked simulated calls

…nts (#462)

When AIMessages contain a 'simulated' flag in response_metadata, this information
is now properly extracted and added to the UiPathConversationToolCallStartEvent
metadata. This enables proper logging and tracing of simulated vs actual tool calls.

Changes:
- Extract simulated flag from AIMessage.response_metadata during tool call processing
- Add simulated flag to tool call event metadata
- Log when a tool call is marked as simulated
- Add comprehensive tests for simulated tool call handling

Fixes #462

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simulated tool call doen't log anything different

1 participant