[Feature Request] Improve embedding sys.user_id usage #12798

Closed
opened 2026-02-21 19:09:05 -05:00 by yindo · 1 comment
Owner

Originally created by @ModyQyW on GitHub (Apr 11, 2025).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Currently, although passing user_id to the embedding can achieve the purpose of sys.user_id, this method still has certain limitations:

  1. Multiple Account Switching Issues

For example, if I first log in to account userA and have a conversation with the chatbot, and then switch to account userB and have a conversation with the chatbot, the recorded account information is still that of userA. This leads to the problem of confusing multiple account identifiers.

  1. Can Only Be Enabled in New Applications

Since we prioritize using existing tokens during implementation, passing user_id to the embedding in old applications will still have no effect unless the user has never obtained a token before. This can lead to difficult-to-understand issues, requiring extra effort for migration and verification.

https://github.com/langgenius/dify/issues/17834

https://github.com/langgenius/dify/pull/16062#issuecomment-2789607751

2. Additional context or comments

Our current token format stored in localStorage is as follows:

{
    "[APP_ID]": "[JWT]"
}

Consider designing v2 of the token format as follows:

{
    "version": 2,
    "[APP_ID]": {
        "DEFAULT": "[JWT]",
        "[USER_ID]": "[JWT]"
    }
}

If no user_id is specified, we get and use the JWT corresponding to DEFAULT; otherwise, we get and use the JWT based on user_id.

If we find that we are using the v1 version of the token, we can consider discarding the token directly and regenerating and storing the v2 version of the token.

Please let me know your thoughts, thank you very much!

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @ModyQyW on GitHub (Apr 11, 2025). ### Self Checks - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. Currently, although passing user_id to the embedding can achieve the purpose of sys.user_id, this method still has certain limitations: 1. Multiple Account Switching Issues For example, if I first log in to account userA and have a conversation with the chatbot, and then switch to account userB and have a conversation with the chatbot, the recorded account information is still that of userA. This leads to the problem of confusing multiple account identifiers. 2. Can Only Be Enabled in New Applications Since we prioritize using existing tokens during implementation, passing user_id to the embedding in old applications will still have no effect unless the user has never obtained a token before. This can lead to difficult-to-understand issues, requiring extra effort for migration and verification. https://github.com/langgenius/dify/issues/17834 https://github.com/langgenius/dify/pull/16062#issuecomment-2789607751 ### 2. Additional context or comments Our current token format stored in localStorage is as follows: ```json { "[APP_ID]": "[JWT]" } ``` Consider designing v2 of the token format as follows: ```json { "version": 2, "[APP_ID]": { "DEFAULT": "[JWT]", "[USER_ID]": "[JWT]" } } ``` If no user_id is specified, we get and use the JWT corresponding to DEFAULT; otherwise, we get and use the JWT based on user_id. If we find that we are using the v1 version of the token, we can consider discarding the token directly and regenerating and storing the v2 version of the token. **Please let me know your thoughts, thank you very much!** ### 3. Can you help us with this feature? - [x] I am interested in contributing to this feature.
yindo added the 💪 enhancement label 2026-02-21 19:09:05 -05:00
yindo closed this issue 2026-02-21 19:09:05 -05:00
Author
Owner

@asrguru20 commented on GitHub (Apr 14, 2025):

same issue

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.[x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).[x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)[x] Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

Currently, although passing user_id to the embedding can achieve the purpose of sys.user_id, this method still has certain limitations:

  1. Multiple Account Switching Issues

For example, if I first log in to account userA and have a conversation with the chatbot, and then switch to account userB and have a conversation with the chatbot, the recorded account information is still that of userA. This leads to the problem of confusing multiple account identifiers.

  1. Can Only Be Enabled in New Applications

Since we prioritize using existing tokens during implementation, passing user_id to the embedding in old applications will still have no effect unless the user has never obtained a token before. This can lead to difficult-to-understand issues, requiring extra effort for migration and verification.

#17834

#16062 (comment)

2. Additional context or comments

Our current token format stored in localStorage is as follows:

{
"[APP_ID]": "[JWT]"
}
Consider designing v2 of the token format as follows:

{
"version": 2,
"[APP_ID]": {
"DEFAULT": "[JWT]",
"[USER_ID]": "[JWT]"
}
}
If no user_id is specified, we get and use the JWT corresponding to DEFAULT; otherwise, we get and use the JWT based on user_id.

If we find that we are using the v1 version of the token, we can consider discarding the token directly and regenerating and storing the v2 version of the token.

Please let me know your thoughts, thank you very much!

3. Can you help us with this feature?

  • I am interested in contributing to this feature.

same issue

@asrguru20 commented on GitHub (Apr 14, 2025): same issue > ### Self Checks > * [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones.[x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)).[x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)[x] Please do not modify this template :) and fill in all the required fields. > > ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. > Currently, although passing user_id to the embedding can achieve the purpose of sys.user_id, this method still has certain limitations: > > 1. Multiple Account Switching Issues > > For example, if I first log in to account userA and have a conversation with the chatbot, and then switch to account userB and have a conversation with the chatbot, the recorded account information is still that of userA. This leads to the problem of confusing multiple account identifiers. > > 2. Can Only Be Enabled in New Applications > > Since we prioritize using existing tokens during implementation, passing user_id to the embedding in old applications will still have no effect unless the user has never obtained a token before. This can lead to difficult-to-understand issues, requiring extra effort for migration and verification. > > [#17834](https://github.com/langgenius/dify/issues/17834) > > [#16062 (comment)](https://github.com/langgenius/dify/pull/16062#issuecomment-2789607751) > > ### 2. Additional context or comments > Our current token format stored in localStorage is as follows: > > { > "[APP_ID]": "[JWT]" > } > Consider designing v2 of the token format as follows: > > { > "version": 2, > "[APP_ID]": { > "DEFAULT": "[JWT]", > "[USER_ID]": "[JWT]" > } > } > If no user_id is specified, we get and use the JWT corresponding to DEFAULT; otherwise, we get and use the JWT based on user_id. > > If we find that we are using the v1 version of the token, we can consider discarding the token directly and regenerating and storing the v2 version of the token. > > **Please let me know your thoughts, thank you very much!** > > ### 3. Can you help us with this feature? > * [x] I am interested in contributing to this feature. same issue
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12798