Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [google] Error: can only concatenate str (not \"list\") to str"} #462

Closed
opened 2026-02-16 10:19:28 -05:00 by yindo · 4 comments
Owner

Originally created by @SAGAYARAJ0 on GitHub (Jul 18, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • 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, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

v1.6.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [google] Error: can only concatenate str (not "list") to str"}

Image

✔️ Expected Behavior

Image

The error comes from the agent. What is the reason for this issue, and how can I find a solution?

Image

Actual Behavior

No response

Originally created by @SAGAYARAJ0 on GitHub (Jul 18, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [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 [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, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version v1.6.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [google] Error: can only concatenate str (not \"list\") to str"} <img width="397" height="260" alt="Image" src="https://github.com/user-attachments/assets/0e9a9783-0f0a-42f8-ac5f-5d937cc5ca9a" /> ### ✔️ Expected Behavior <img width="397" height="260" alt="Image" src="https://github.com/user-attachments/assets/bffcc0c2-872e-414a-a712-f26c815feda4" /> The error comes from the agent. What is the reason for this issue, and how can I find a solution? <img width="351" height="221" alt="Image" src="https://github.com/user-attachments/assets/544086b0-76a8-4a88-b5c4-d3722bc98367" /> ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-16 10:19:28 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 18, 2025):

Hi @SAGAYARAJ0! I'm Dosu and I’m helping the dify team.

This error happens because Dify's agent logic expects LLM responses to be strings, but some providers (like Google Gemini) can return a list (often for multimodal or structured outputs). When the code tries to concatenate a string with a list, you get the "can only concatenate str (not 'list') to str" TypeError. This is a known issue in the Dify codebase, especially when integrating with plugin-based providers that may emit lists instead of plain text strings [source].

Recent PRs have addressed this in some places by adding type checks and flattening lists to strings where needed (see PR langgenius/dify#21837 and langgenius/dify#22036). To work around this, you can patch your deployment by ensuring that wherever message content is consumed or transformed (especially in agent runners or message transformation logic), you check if the content is a list and join or extract the text segments before concatenating. For example:

if isinstance(content, list):
    content = "".join(item.data for item in content if hasattr(item, "data"))

This will prevent the TypeError and ensure compatibility with providers that return structured or multimodal outputs. If you update to a version after these PRs, or apply a similar patch, the issue should be resolved.

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 (Jul 18, 2025): <!-- Greeting --> Hi @SAGAYARAJ0! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> This error happens because Dify's agent logic expects LLM responses to be strings, but some providers (like Google Gemini) can return a list (often for multimodal or structured outputs). When the code tries to concatenate a string with a list, you get the "can only concatenate str (not 'list') to str" TypeError. This is a known issue in the Dify codebase, especially when integrating with plugin-based providers that may emit lists instead of plain text strings [[source]](https://github.com/langgenius/dify/blob/dba42567b178e0fb266090e9703ec085e5c1c80b/api/core/model_runtime/model_providers/__base/large_language_model.py). Recent PRs have addressed this in some places by adding type checks and flattening lists to strings where needed (see PR langgenius/dify#21837 and langgenius/dify#22036). To work around this, you can patch your deployment by ensuring that wherever message content is consumed or transformed (especially in agent runners or message transformation logic), you check if the content is a list and join or extract the text segments before concatenating. For example: ```python if isinstance(content, list): content = "".join(item.data for item in content if hasattr(item, "data")) ``` This will prevent the TypeError and ensure compatibility with providers that return structured or multimodal outputs. If you update to a version after these PRs, or apply a similar patch, the issue should be resolved. <!-- 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/e1f898aa-7d05-4aa9-9b6d-82c718625602?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/e1f898aa-7d05-4aa9-9b6d-82c718625602?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/e1f898aa-7d05-4aa9-9b6d-82c718625602?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/e1f898aa-7d05-4aa9-9b6d-82c718625602?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e1f898aa-7d05-4aa9-9b6d-82c718625602?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/e1f898aa-7d05-4aa9-9b6d-82c718625602?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e1f898aa-7d05-4aa9-9b6d-82c718625602?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/issues/22634)
Author
Owner

@crazywoola commented on GitHub (Jul 18, 2025):

Please provide the plugin version as well.

@crazywoola commented on GitHub (Jul 18, 2025): Please provide the plugin version as well.
Author
Owner

@gokulavelan commented on GitHub (Jul 23, 2025):

Version 0.2.8

@gokulavelan commented on GitHub (Jul 23, 2025): Version 0.2.8
Author
Owner

@dosubot[bot] commented on GitHub (Aug 21, 2025):

Hi, @SAGAYARAJ0. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported a PluginInvokeError in Dify v1.6.0 caused by a TypeError when concatenating a string with a list during LLM model reading.
  • The root cause was identified as some providers returning lists instead of strings.
  • Recent pull requests have addressed this by flattening lists to strings before concatenation.
  • A workaround patch was suggested to join list contents before concatenation.
  • Plugin version 0.2.8 was confirmed during the discussion.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of dify-official-plugins by commenting here.
  • Otherwise, this issue will be automatically closed in 5 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 21, 2025): Hi, @SAGAYARAJ0. I'm [Dosu](https://dosu.dev), and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported a PluginInvokeError in Dify v1.6.0 caused by a TypeError when concatenating a string with a list during LLM model reading. - The root cause was identified as some providers returning lists instead of strings. - Recent pull requests have addressed this by flattening lists to strings before concatenation. - A workaround patch was suggested to join list contents before concatenation. - Plugin version 0.2.8 was confirmed during the discussion. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of dify-official-plugins by commenting here. - Otherwise, this issue will be automatically closed in 5 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#462