Skip to content

Unable to have a normal conversation with the agent in the chat box after token expiration #10863

@llinvokerl

Description

@llinvokerl

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • 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.

Dify version

0.11.2

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. Modify the environment variable ACCESS_TOKEN_EXPIRE_MINUTES to "1", so the access token will expire in 1 minute.
  2. Enter the agent's Debug and Preview interface and send a message, triggering the /chat-messages API.
  3. Wait 1 minute for the token to expire, then send another message, calling /chat-messages again.

After completing the steps mentioned above, the browser starts an infinite loop, alternately calling /refresh-token and /chat-messages, while the chat box continually shows the agent as "speaking."

This issue occurs because, after the frontend receives a 401 unauthorized response from the /chat-messages call, it requests a token refresh. However, when it calls /chat-messages again, it doesn't use the new token. Since the old token has expired, it still gets a 401 unauthorized response from /chat-messages. As a result, the frontend keeps requesting /refresh-token, but this effort is in vain.

✔️ Expected Behavior

image
After using /refresh-token, it's necessary to explicitly use the updated token when calling /chat-messages again.

❌ Actual Behavior

image
image
image

Metadata

Metadata

Assignees

Labels

🐞 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions