Fix Langfuse callback passthrough in RunnableRails (#472) #1390
+39
−1
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 #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
RunnableRails.invoke()
to store theRunnableConfig
and kwargs for later use in the passthrough function_init_passthrough_fn()
to use the stored config when invoking the passthrough runnabletest_runnable_config_callback_passthrough()
to verify that callbacks are properly propagatedTechnical Details
The issue occurred because:
RunnableRails.invoke()
received aconfig
parameter with callbackspassthrough_fn
was called asynchronously through the Rails systemconfig
wasn't available in the passthrough function scopeTesting
This ensures that tracing libraries like Langfuse work correctly when using RunnableRails in LangChain chains.