Skip to content

Conversation

Pouyanpi
Copy link
Collaborator

@Pouyanpi Pouyanpi commented Sep 19, 2025

Description

Summary

  • Fixes tool calling failures when using RunnableRails with passthrough=True
  • Refactors message conversion logic into reusable utilities
  • Ensures all message metadata is preserved during LangChain format conversions

Changes

  • Created message_utils.py with centralized message conversion functions
  • Updated RunnableRails to use message_utils instead of hardcoded conversions
  • Modified utils.py to dynamically preserve all message fields

@Pouyanpi Pouyanpi self-assigned this Sep 19, 2025
@Pouyanpi Pouyanpi added this to the v0.17.0 milestone Sep 19, 2025
Copy link
Collaborator

@tgasser-nv tgasser-nv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. The only issue I can see is that Langchain doesn't support OpenAI's new developer role. We can handle this by treating developer turns the same as system ones (that they're replacing).

Some other nits to address before merging.

@Pouyanpi Pouyanpi force-pushed the feat/tool-calling-input branch from c8ff064 to 5792bea Compare September 22, 2025 09:11
Base automatically changed from feat/tool-calling-input to develop September 22, 2025 09:39
- Extract message conversion logic to centralized message_utils module
  - Dynamically preserve all LangChain message fields (tool_calls,
additional_kwargs, etc.)
  - Fix tool calling metadata loss in passthrough mode
  - Add comprehensive unit tests for message conversions
@Pouyanpi Pouyanpi force-pushed the fix/message-metadata-lc branch from 7b6b0ba to 5a33601 Compare September 22, 2025 09:47
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 93.82716% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...uardrails/integrations/langchain/runnable_rails.py 81.57% 7 Missing ⚠️
...guardrails/integrations/langchain/message_utils.py 97.54% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Pouyanpi Pouyanpi merged commit 38d1892 into develop Sep 22, 2025
8 checks passed
@Pouyanpi Pouyanpi deleted the fix/message-metadata-lc branch September 22, 2025 10:17
tgasser-nv pushed a commit that referenced this pull request Sep 22, 2025
…calling (#1405)

* fix: preserve message metadata in RunnableRails tool calling

- Extract message conversion logic to centralized message_utils module
  - Dynamically preserve all LangChain message fields (tool_calls,
additional_kwargs, etc.)
  - Fix tool calling metadata loss in passthrough mode
  - Add comprehensive unit tests for message conversions
tgasser-nv pushed a commit that referenced this pull request Sep 22, 2025
…calling (#1405)

* fix: preserve message metadata in RunnableRails tool calling

- Extract message conversion logic to centralized message_utils module
  - Dynamically preserve all LangChain message fields (tool_calls,
additional_kwargs, etc.)
  - Fix tool calling metadata loss in passthrough mode
  - Add comprehensive unit tests for message conversions
Pouyanpi added a commit that referenced this pull request Oct 1, 2025
…calling (#1405)

* fix: preserve message metadata in RunnableRails tool calling

- Extract message conversion logic to centralized message_utils module
  - Dynamically preserve all LangChain message fields (tool_calls,
additional_kwargs, etc.)
  - Fix tool calling metadata loss in passthrough mode
  - Add comprehensive unit tests for message conversions
tgasser-nv pushed a commit that referenced this pull request Oct 14, 2025
…calling (#1405)

* fix: preserve message metadata in RunnableRails tool calling

- Extract message conversion logic to centralized message_utils module
  - Dynamically preserve all LangChain message fields (tool_calls,
additional_kwargs, etc.)
  - Fix tool calling metadata loss in passthrough mode
  - Add comprehensive unit tests for message conversions
tgasser-nv pushed a commit that referenced this pull request Oct 14, 2025
…calling (#1405)

* fix: preserve message metadata in RunnableRails tool calling

- Extract message conversion logic to centralized message_utils module
  - Dynamically preserve all LangChain message fields (tool_calls,
additional_kwargs, etc.)
  - Fix tool calling metadata loss in passthrough mode
  - Add comprehensive unit tests for message conversions
tgasser-nv pushed a commit that referenced this pull request Oct 14, 2025
…calling (#1405)

* fix: preserve message metadata in RunnableRails tool calling

- Extract message conversion logic to centralized message_utils module
  - Dynamically preserve all LangChain message fields (tool_calls,
additional_kwargs, etc.)
  - Fix tool calling metadata loss in passthrough mode
  - Add comprehensive unit tests for message conversions
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.

3 participants