Memory Node mem0 Ignores Specified User ID
Bug Description
I'm experiencing an issue with the memory node mem0 in Langflow 1.1.1
-
User ID Ignored: This node relies on a "User ID" variable to differentiate information between users, similar to how Langflow uses Session IDs. However, modifying the "User ID" variable within the node—either through the UI or via API—has no effect. The node consistently uses the User ID of the logged-in user or the creator of the API key, disregarding the specified "User ID" variable.
-
Variable Renaming Error: Changing the name of the
user_idvariable within the node results in an error, similar to the one reported in Issue #5019.Error building Component Mem0 Chat Memory: variable not found. Traceback (most recent call last): File "/app/.venv/lib/python3.12/site-packages/langflow/graph/vertex/base.py", line 709, in _build_results result = await initialize.loading.get_instance_results( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/langflow/interface/initialize/loading.py", line 60, in get_instance_results custom_params = update_params_with_load_from_db_fields( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/langflow/interface/initialize/loading.py", line 118, in update_params_with_load_from_db_fields key = custom_component.variables(params[field], field) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/langflow/custom/custom_component/custom_component.py", line 432, in get_variable return variable_service.get_variable(user_id=user_id, name=name, field=field, session=session) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.12/site-packages/langflow/services/variable/service.py", line 69, in get_variable raise ValueError(msg) ValueError: variable not found.
Possible Causes
User ID Conflict:
- The
mem0node uses a variable nameduser_id, which conflicts with Langflow's internaluser_idvariable used for session management. - This naming conflict causes the node to override the specified "User ID" with the session's User ID.
Variable Dependency:
- The node may have hard-coded dependencies on the
user_idvariable name. - Changing the variable name breaks these dependencies, leading to the error.
Security Implications
- Data Leakage Risk: Users may inadvertently access or manipulate data intended for other users.
- Information Security Concerns: The inability to isolate user data can lead to breaches of confidentiality and trust within the application.
Reproduction
1. User ID Ignored:
- Create a flow that includes the
mem0memory node. - In the node's settings, set the "User ID" variable to a value different from the current session's User ID.
- Execute the flow via the UI or API.
- Observe that the node still uses the session's User ID instead of the one specified.
2. Variable Renaming Error:
- In the
mem0node, attempt to rename theuser_idvariable to something else (e.g.,custom_user_id). - Execute the flow.
- Observe that the flow fails with the error message provided above.
Expected behavior
Changing the "User ID" variable in the mem0 node should direct the node to use the specified User ID for data differentiation between users.
Who can help?
No response
Operating System
Ubuntu 24.04.1 LTS (GNU/Linux 6.8.0-49-generic x86_64)
Langflow Version
1.1.1
Python Version
3.12
Screenshot
No response
Flow File
No response
The issue you're experiencing with the mem0 memory node in Langflow seems to be related to how the user_id variable is handled internally. The mem0 node uses the user_id to associate messages with specific users, and it appears that there might be a conflict between the user_id variable used in the node and Langflow's internal session management system.
-
User ID Ignored: The
mem0node uses theuser_idvariable to store and retrieve messages. If the node is defaulting to the session's User ID instead of the specified User ID, it could be due to a conflict or hard-coded dependency on theuser_idvariable name. This behavior is consistent with the node's design, which uses theuser_idfor identifying user-specific data [1]. -
Variable Renaming Error: Renaming the
user_idvariable results in a 'variable not found' error. This is likely because the node has dependencies on theuser_idvariable name, and changing it breaks these dependencies. The error handling in themem0node logs a warning if theuser_idis missing, which might be contributing to the error you're seeing [1].
To address these issues, you might need to ensure that the user_id variable is correctly set and passed within the node. Additionally, reviewing the node's implementation for any hard-coded dependencies on the user_id variable name could help identify potential areas for modification.
To continue talking to Dosu, mention @dosu.