Skip to content

Conversation

@HenryHengZJ
Copy link
Contributor

Problem

The resolveVariables function in buildAgentflow.ts was not properly resolving variables in array-based configuration objects. When processing parameters like agentTools (which is an array), only the first item's config object was being processed, leaving subsequent array items with unresolved variables.

Root Cause

  1. The findParamValue function only returned the first match found in arrays
  2. The processConfigParams function didn't handle arrays of config objects
  3. The processing logic only handled single config objects, not arrays of configs

Solution

  • Enhanced processConfigParams: Added array handling to recursively process each item in config arrays
  • Created findAllConfigValues: New function to find ALL config objects in arrays instead of just the first one
  • Updated processing logic: Now processes all found config objects instead of just the first match

Changes Made

  • Modified processConfigParams to handle arrays of config objects
  • Added findAllConfigValues helper function for comprehensive array traversal
  • Updated the config processing loop to iterate through all found config values

Testing

  • Tested with agentTools array containing multiple requestsGet tools
  • Verified that variables like {{ $flow.state.test }} are now resolved in all array items
  • Confirmed backward compatibility with single config objects

Example

Before: Only first tool's requestsGetUrl had variables resolved

"agentTools": [
  {
    "agentSelectedToolConfig": {
      "requestsGetUrl": "http://localhost:5566/events?resolved_value" // ✅ Resolved
    }
  },
  {
    "agentSelectedToolConfig": {
      "requestsGetUrl": "http://localhost:5566/events?{{ $flow.state.test }}" // ❌ Not resolved
    }
  }
]

After: All tools' configs have variables resolved

"agentTools": [
  {
    "agentSelectedToolConfig": {
      "requestsGetUrl": "http://localhost:5566/events?resolved_value" // ✅ Resolved
    }
  },
  {
    "agentSelectedToolConfig": {
      "requestsGetUrl": "http://localhost:5566/events?resolved_value" // ✅ Resolved
    }
  }
]

Impact

  • Fixes variable resolution in array-based node configurations
  • Improves reliability of agent tools and other array-based parameters
  • Maintains backward compatibility with existing single config objects

- Added handling for arrays of config objects in the resolveVariables function.
- Implemented a recursive search for config values to process all matching parameters, improving flexibility in variable resolution.
@HenryHengZJ HenryHengZJ merged commit f3f2eab into main Oct 21, 2025
2 checks passed
@maggi2508
Copy link

maggi2508 commented Oct 21, 2025

@HenryHengZJ
Is this fixed in flowise cloud as well (or) when would it get fixed ?

@maggi2508
Copy link

Hi @HenryHengZJ - Can you please suggest when this would be fixed in Flowise Cloud ?

@maggi2508
Copy link

Can someone confirm when this fix will be applied and available on Flowise Cloud ? We have tested this multiple times and hasn’t been working yet.
It would be very helpful if there are some pointers around when we can see this made available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flowise state variables are accessible only to the first tool included in an agent, not to subsequent tools

3 participants