The Agent uses the qwen model. When memory is enabled, an error occurs after sending a document message and then sending another message. #671

Closed
opened 2026-02-16 10:20:08 -05:00 by yindo · 3 comments
Owner

Originally created by @lucidity99 on GitHub (Sep 24, 2025).

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 Dify issues & Dify Official Plugins, 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

1.8.0

Plugin version

通义千问 0.0.47

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Create a new chatflow, use the Agent node, select any qwen model, and enable memory.
  2. Send a document, and after receiving the reply, send the task text again.
  3. An error is returned.

✔️ Error log

Run failed: Failed to transform agent message: req_id: 48266379f3 PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [tongyi] Error: req_id: 2ecafaa296 PluginInvokeError: {"args":{"description":"[models] Error: 'dict' object has no attribute 'dashscope_api_key'"},"error_type":"InvokeError","message":"[models] Error: 'dict' object has no attribute 'dashscope_api_key'"}"}

Originally created by @lucidity99 on GitHub (Sep 24, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/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. ### Dify version 1.8.0 ### Plugin version 通义千问 0.0.47 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Create a new chatflow, use the Agent node, select any qwen model, and enable memory. 2. Send a document, and after receiving the reply, send the task text again. 3. An error is returned. ### ✔️ Error log Run failed: Failed to transform agent message: req_id: 48266379f3 PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [tongyi] Error: req_id: 2ecafaa296 PluginInvokeError: {"args":{"description":"[models] Error: 'dict' object has no attribute 'dashscope_api_key'"},"error_type":"InvokeError","message":"[models] Error: 'dict' object has no attribute 'dashscope_api_key'"}"}
yindo added the bug label 2026-02-16 10:20:08 -05:00
yindo closed this issue 2026-02-16 10:20:08 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 24, 2025):

The error is caused by a bug in the Tongyi (qwen) plugin: the code tries to access the API key using dot notation (credentials.dashscope_api_key), but credentials are passed as a dictionary, so it should use credentials['dashscope_api_key'] instead. This leads to the 'dict' object has no attribute 'dashscope_api_key' error when memory is enabled and the agent node tries to make an API request [details & fix].

To fix this, update the plugin code in the _upload_file_to_tongyi method (and any similar places) to use dictionary key access. If you can't patch the code, you can try these workarounds: downgrade the Tongyi plugin to version 0.0.18 (users report this avoids the bug in recent Dify releases), or switch the agent node strategy from EnhanceFunctionCalling to Dify's official agent strategy, which has resolved similar errors for others [workaround].

Also, double-check that your provider configuration includes the correct dashscope_api_key value, with no typos or formatting issues [config advice]. If you update the plugin or config and still see the error, let me know if you need a sample config or more details.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 24, 2025): <!-- Answer --> The error is caused by a bug in the Tongyi (qwen) plugin: the code tries to access the API key using dot notation (`credentials.dashscope_api_key`), but credentials are passed as a dictionary, so it should use `credentials['dashscope_api_key']` instead. This leads to the `'dict' object has no attribute 'dashscope_api_key'` error when memory is enabled and the agent node tries to make an API request [[details & fix](https://github.com/langgenius/dify-official-plugins/issues/917)]. To fix this, update the plugin code in the `_upload_file_to_tongyi` method (and any similar places) to use dictionary key access. If you can't patch the code, you can try these workarounds: downgrade the Tongyi plugin to version 0.0.18 (users report this avoids the bug in recent Dify releases), or switch the agent node strategy from EnhanceFunctionCalling to Dify's official agent strategy, which has resolved similar errors for others [[workaround](https://github.com/langgenius/dify/issues/25116#issuecomment-3251432861)]. Also, double-check that your provider configuration includes the correct `dashscope_api_key` value, with no typos or formatting issues [[config advice](https://github.com/langgenius/dify/issues/21484#issuecomment-3003697666)]. If you update the plugin or config and still see the error, let me know if you need a sample config or more details. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/b1c7d7df-cc41-40a0-ad70-f5b530f9b579?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/b1c7d7df-cc41-40a0-ad70-f5b530f9b579?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/b1c7d7df-cc41-40a0-ad70-f5b530f9b579?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/b1c7d7df-cc41-40a0-ad70-f5b530f9b579?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/b1c7d7df-cc41-40a0-ad70-f5b530f9b579?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/b1c7d7df-cc41-40a0-ad70-f5b530f9b579?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/b1c7d7df-cc41-40a0-ad70-f5b530f9b579?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/1762)
Author
Owner

@lucidity99 commented on GitHub (Sep 24, 2025):

Hi @dosu , based on the solutions you provided, I have tried the following steps:

  1. Downgraded the Tongyi plugin to version 0.0.18 and version 0.0.16 respectively.
  2. Modified the Agent strategy to FunctionCalling and ReAct under Dify's official agent strategy.

However, the issue still persists.

@lucidity99 commented on GitHub (Sep 24, 2025): Hi @dosu , based on the solutions you provided, I have tried the following steps: 1. Downgraded the Tongyi plugin to version 0.0.18 and version 0.0.16 respectively. 2. Modified the Agent strategy to FunctionCalling and ReAct under Dify's official agent strategy. However, the issue still persists.
Author
Owner

@dosubot[bot] commented on GitHub (Sep 24, 2025):

The error persists because the Tongyi plugin has a bug where it sometimes tries to access the API key using dot notation (credentials.dashscope_api_key) instead of dictionary access (credentials['dashscope_api_key']). This bug is present in both recent and older plugin versions, and downgrading or switching agent strategies often doesn't resolve it—especially when memory is enabled in agent nodes. The only robust fix is to patch the plugin code so all credential access uses dictionary keys, or to ensure credentials are always normalized before use.

Also, double-check that your API key starts with sk-, matches the expected provider config, and that your endpoint (domestic/international) is correct. Even if the UI shows the key as valid, backend validation may still reject it if the format or config is off. In self-hosted or firewalled environments, make sure Dify can reach the Tongyi API endpoints, and check backend logs for more details if the error continues. If you need to skip key validation or patch the plugin, you can fork the repo and adjust the credential handling logic as needed. More details and config tips are here: API key and config advice, plugin credential handling, prompt message requirements.

If you want a minimal workaround: try disabling memory, or use a different model/plugin to confirm the issue is isolated to Tongyi + memory. If you need a sample config or code patch, let me know.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 24, 2025): <!-- Answer --> The error persists because the Tongyi plugin has a bug where it sometimes tries to access the API key using dot notation (`credentials.dashscope_api_key`) instead of dictionary access (`credentials['dashscope_api_key']`). This bug is present in both recent and older plugin versions, and downgrading or switching agent strategies often doesn't resolve it—especially when memory is enabled in agent nodes. The only robust fix is to patch the plugin code so all credential access uses dictionary keys, or to ensure credentials are always normalized before use. Also, double-check that your API key starts with `sk-`, matches the expected provider config, and that your endpoint (domestic/international) is correct. Even if the UI shows the key as valid, backend validation may still reject it if the format or config is off. In self-hosted or firewalled environments, make sure Dify can reach the Tongyi API endpoints, and check backend logs for more details if the error continues. If you need to skip key validation or patch the plugin, you can fork the repo and adjust the credential handling logic as needed. More details and config tips are here: [API key and config advice](https://github.com/langgenius/dify/issues/22442#issuecomment-3073536284), [plugin credential handling](https://github.com/langgenius/dify-official-plugins/issues/1287#issuecomment-3074105647), [prompt message requirements](https://github.com/langgenius/dify/issues/18495#issuecomment-2820358739). If you want a minimal workaround: try disabling memory, or use a different model/plugin to confirm the issue is isolated to Tongyi + memory. If you need a sample config or code patch, let me know. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/dfb910e9-0c34-4fc5-8262-ab049ad16152?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/dfb910e9-0c34-4fc5-8262-ab049ad16152?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/dfb910e9-0c34-4fc5-8262-ab049ad16152?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/dfb910e9-0c34-4fc5-8262-ab049ad16152?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/dfb910e9-0c34-4fc5-8262-ab049ad16152?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/dfb910e9-0c34-4fc5-8262-ab049ad16152?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/dfb910e9-0c34-4fc5-8262-ab049ad16152?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/1762)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#671