You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the LANGFUSE-related env variables are configured, executing a flow with only a single agent sends three traces to Langfuse, two of which are not controlled by Langflow code. (This is particularly problematic as I'm currently working on a PR to submit meta information like session_id/user_id in the trace.)
But in Langflow, we didn't enable this feature. I traced the call stack and found that in the dspy package, the openai module is arbitrarily patched (using the drop-in trick of langfuse), causing unexpected traces to be sent to Langfuse, which aren't controlled by our src/backend/base/langflow/services/tracing/langfuse.py.
Modify langflow/services/tracing/langwatch.py to prevent setup_langwatch from being called if the LANGWATCH configuration is absent (the issue stems from dspy being imported in langwatch's initialization).
If Langflow doesn't require dspy (I couldn't find any usage of it in the code), why not remove it entirely?
Consider submitting a modification suggestion to the maintainers of dspy, though it may not necessarily be accepted.
For option 1, I could help submit a PR. However, someone needs to confirm this solution.
The issue you're encountering seems to be related to the dspy package, which is causing unexpected traces to be sent to Langfuse due to its integration with the OpenAI package. Here are some steps you can consider to address this:
Modify langwatch.py: You can adjust the langflow/services/tracing/langwatch.py file to ensure that setup_langwatch is not called if the LANGWATCH configuration is absent. This could prevent the unintended behavior caused by the dspy package during initialization.
Evaluate the Necessity of dspy: If dspy is not essential for Langflow's core functionality, consider removing it from the dependencies. According to the pyproject.toml, the dspy package itself is not listed, but dspy-ai is included [1].
Submit a PR: If you are confident in the solution, you can submit a pull request to implement the changes in langwatch.py. This would require confirmation from the maintainers or contributors to ensure it aligns with the project's goals.
Contact dspy Maintainers: If the issue persists and is directly related to dspy, consider reaching out to its maintainers with a suggestion to modify the behavior. However, this might not be accepted, so it's a secondary option.
These steps should help mitigate the issue of unexpected traces being sent to Langfuse.
Bug Description
Issue:
When the LANGFUSE-related env variables are configured, executing a flow with only a single agent sends three traces to Langfuse, two of which are not controlled by Langflow code. (This is particularly problematic as I'm currently working on a PR to submit meta information like session_id/user_id in the trace.)
Cause Analysis:
Langfuse provides a drop-in replacement for the OpenAI package, which monkey patches OpenAI's model invocation functions and reads LANGFUSE-related environment variables.
But in Langflow, we didn't enable this feature. I traced the call stack and found that in the
dspy
package, theopenai
module is arbitrarily patched (using the drop-in trick of langfuse), causing unexpected traces to be sent to Langfuse, which aren't controlled by oursrc/backend/base/langflow/services/tracing/langfuse.py
.call_stack here:
full traceback stack.log
Suggested Solution:
langflow/services/tracing/langwatch.py
to prevent setup_langwatch from being called if the LANGWATCH configuration is absent (the issue stems from dspy being imported in langwatch's initialization).For option 1, I could help submit a PR. However, someone needs to confirm this solution.
Reproduction
Expected behavior
how to solve it
Who can help?
@italojohnny
Operating System
macos
Langflow Version
1.1.4
Python Version
3.12
Screenshot
No response
Flow File
simple_agent.json
The text was updated successfully, but these errors were encountered: