[PR #31780] fix: auto-inject sys.files for files type parameters in iteration nodes #33406

Open
opened 2026-02-21 20:53:13 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/31780

State: open
Merged: No


Summary

  • Fix a bug where FILES or SYSTEM_FILES type parameters are lost after the first iteration when tools are used inside iteration nodes
  • The issue occurs when users don't explicitly configure the files parameter (expecting it to be auto-injected from sys.files)
  • Add auto-injection logic in _generate_parameters() to properly pass sys.files to tools in all iterations

Root Cause

The _generate_parameters() method in tool_node.py only iterates over node_data.tool_parameters (user-configured parameters). When a tool defines a FILES or SYSTEM_FILES type parameter with form: form, and the user doesn't explicitly configure it in the workflow (expecting the system to auto-inject from sys.files), the parameter is never processed.

This works on the first iteration because tool_runtime.runtime_parameters has cached file values, but subsequent iterations use new tool_runtime instances where the cache is empty.

Test Plan

  • Create a workflow with an iteration node containing a tool that has a files type parameter
  • Upload multiple files and run the workflow
  • Verify all iterations receive the files parameter correctly (not just the first one)

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/langgenius/dify/pull/31780 **State:** open **Merged:** No --- ## Summary - Fix a bug where `FILES` or `SYSTEM_FILES` type parameters are lost after the first iteration when tools are used inside iteration nodes - The issue occurs when users don't explicitly configure the files parameter (expecting it to be auto-injected from `sys.files`) - Add auto-injection logic in `_generate_parameters()` to properly pass `sys.files` to tools in all iterations ## Root Cause The `_generate_parameters()` method in `tool_node.py` only iterates over `node_data.tool_parameters` (user-configured parameters). When a tool defines a `FILES` or `SYSTEM_FILES` type parameter with `form: form`, and the user doesn't explicitly configure it in the workflow (expecting the system to auto-inject from `sys.files`), the parameter is never processed. This works on the first iteration because `tool_runtime.runtime_parameters` has cached file values, but subsequent iterations use new `tool_runtime` instances where the cache is empty. ## Test Plan - [ ] Create a workflow with an iteration node containing a tool that has a `files` type parameter - [ ] Upload multiple files and run the workflow - [ ] Verify all iterations receive the files parameter correctly (not just the first one) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
yindo added the pull-request label 2026-02-21 20:53:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33406