Skip to content

Conversation

divya-garak
Copy link

Summary

Fixes #472: This PR resolves the issue where Langfuse tracing integration was broken when using NeMo-Guardrails with LangChain chains.

The problem was that the RunnableConfig containing callbacks wasn't being properly passed through to the underlying LLM runnable in the passthrough function.

Changes Made

  • Store config and kwargs: Modified RunnableRails.invoke() to store the RunnableConfig and kwargs for later use in the passthrough function
  • Pass config to underlying runnable: Updated _init_passthrough_fn() to use the stored config when invoking the passthrough runnable
  • Added comprehensive test: Created test_runnable_config_callback_passthrough() to verify that callbacks are properly propagated

Technical Details

The issue occurred because:

  1. RunnableRails.invoke() received a config parameter with callbacks
  2. The passthrough_fn was called asynchronously through the Rails system
  3. The original config wasn't available in the passthrough function scope
  4. Callbacks (like Langfuse tracing) weren't being called

Testing

  • ✅ All existing tests continue to pass
  • ✅ New test verifies callback passthrough functionality
  • ✅ Tested with passthrough mode scenarios

This ensures that tracing libraries like Langfuse work correctly when using RunnableRails in LangChain chains.

Fixes NVIDIA#472: The langchain runnable was not called with the runnable
config that defines callbacks, breaking Langfuse tracing integration.

Changes:
- Store RunnableConfig and kwargs from invoke() for use in passthrough function
- Pass stored config to underlying runnable to preserve callbacks
- Add test to verify callback passthrough functionality

This ensures that callbacks (like Langfuse tracing) are properly
propagated to the underlying LLM runnable wrapped in RunnableRails.
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.

NeMo-Guardrails breaks Langfuse integration / Runnable config is ignored in LLM call
1 participant