Agent Node JSON Not Serializable Error File Upload #22203

Open
opened 2026-02-21 20:16:08 -05:00 by yindo · 1 comment
Owner

Originally created by @lema-founders on GitHub (Feb 12, 2026).

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

1.13.0

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. File array list input
Image
  1. Agent node
Image
  1. Upload image
Image

✔️ Expected Behavior

Agent node runs successfully and able to recognize the image

Actual Behavior

Object of type File is not JSON serializable

Image
Originally created by @lema-founders on GitHub (Feb 12, 2026). ### 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 1.13.0 ### Cloud or Self Hosted Self Hosted (Source) ### Steps to reproduce 1. File array list input <img width="481" height="913" alt="Image" src="https://github.com/user-attachments/assets/e53921ab-f2f4-4b43-8eaa-b24d37df922a" /> 2. Agent node <img width="1433" height="797" alt="Image" src="https://github.com/user-attachments/assets/060cf457-c888-4b92-8cde-9ffb6e6734d5" /> 3. Upload image <img width="797" height="545" alt="Image" src="https://github.com/user-attachments/assets/8ca13787-821c-48ed-b3ff-3f30c20fd110" /> ### ✔️ Expected Behavior Agent node runs successfully and able to recognize the image ### ❌ Actual Behavior Object of type File is not JSON serializable <img width="461" height="469" alt="Image" src="https://github.com/user-attachments/assets/ab4265bf-e84c-45af-a3b3-7436b1ca9d4f" />
yindo added the 🐞 bug label 2026-02-21 20:16:08 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 12, 2026):

This is a known issue affecting file/image handling in agent nodes. Here are some workarounds you can try:

  1. Reference images in User Prompt, not System Prompt - There's a serialization logic gap where System Prompts don't properly convert image variables to JSON-serializable format, but User Prompts do.

  2. Ensure your file variable is configured as FILES type (array) - The variable should always be an array type, even for single files. Make sure the output type is FILES not FILE.

  3. Update your plugins - Ensure you're using recent plugin versions: OpenAI plugin >= 0.0.14, Azure OpenAI >= 0.0.11, OpenRouter >= 0.0.6.

This is a systemic issue that's been reported across multiple workflows. Recent fixes have been merged to address related serialization problems (PR #30464), so upgrading to the latest version may also help.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Feb 12, 2026): <!-- Answer --> This is a known issue affecting file/image handling in agent nodes. Here are some workarounds you can try: 1. **Reference images in User Prompt, not System Prompt** - There's a [serialization logic gap](https://github.com/langgenius/dify-official-plugins/issues/1118#issuecomment-2982774797) where System Prompts don't properly convert image variables to JSON-serializable format, but User Prompts do. 2. **Ensure your file variable is configured as FILES type (array)** - The variable should always be an array type, even for single files. Make sure the output type is `FILES` not `FILE`. 3. **Update your plugins** - Ensure you're using recent plugin versions: [OpenAI plugin >= 0.0.14, Azure OpenAI >= 0.0.11, OpenRouter >= 0.0.6](https://github.com/langgenius/dify/issues/30713#issuecomment-3720995199). This is a [systemic issue](https://github.com/langgenius/dify/issues/30713) that's been reported across multiple workflows. Recent fixes have been merged to address related serialization problems ([PR #30464](https://github.com/langgenius/dify/pull/30464)), so upgrading to the latest version may also help. <!-- 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/90361a1a-f1bf-4948-b8aa-10302e431083?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/90361a1a-f1bf-4948-b8aa-10302e431083?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/90361a1a-f1bf-4948-b8aa-10302e431083?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/90361a1a-f1bf-4948-b8aa-10302e431083?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/90361a1a-f1bf-4948-b8aa-10302e431083?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/90361a1a-f1bf-4948-b8aa-10302e431083?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/90361a1a-f1bf-4948-b8aa-10302e431083?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20issue%20affecting%20file/image%20handling%20in%20agent%20nodes.%20Here%20are%20some%20workarounds%20you%20can%20try%3A%0A%0A1.%20%2A%2AReference%20images%20in%20User%20Prompt%2C%20not%20System%20Prompt%2A%2A%20-%20There%27s%20a%20%5Bserialization%20logic%20gap%5D%28https%3A//github.com/langgenius/dify-official-plugins/issues/1118%23issuecomment-2982774797%29%20where%20System%20Prompts%20don%27t%20properly%20convert%20image%20variables%20to%20JSON-serializable%20format%2C%20but%20User%20Prompts%20do.%0A%0A2.%20%2A%2AEnsure%20your%20file%20variable%20is%20configured%20as%20FILES%20type%20%28array%29%2A%2A%20-%20The%20variable%20should%20always%20be%20an%20array%20type%2C%20even%20for%20single%20files.%20Make%20sure%20the%20output%20type%20is%20%60FILES%60%20not%20%60FILE%60.%0A%0A3.%20%2A%2AUpdate%20your%20plugins%2A%2A%20-%20Ensure%20you%27re%20using%20recent%20plugin%20versions%3A%20%5BOpenAI%20plugin%20%3E%3D%200.0.14%2C%20Azure%20OpenAI%20%3E%3D%200.0.11%2C%20OpenRouter%20%3E%3D%200.0.6%5D%28https%3A//github.com/langgenius/dify/issues/30713%23issuecomment-3720995199%29.%0A%0AThis%20is%20a%20%5Bsystemic%20issue%5D%28https%3A//github.com/langgenius/dify/issues/30713%29%20that%27s%20been%20reported%20across%20multiple%20workflows.%20Recent%20fixes%20have%20been%20merged%20to%20address%20related%20serialization%20problems%20%28%5BPR%20%2330464%5D%28https%3A//github.com/langgenius/dify/pull/30464%29%29%2C%20so%20upgrading%20to%20the%20latest%20version%20may%20also%20help.)&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/32261)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#22203