@@ -227,6 +227,37 @@ class Tool_Agentflow implements INode {
227
227
228
228
let toolCallArgs : Record < string , any > = { }
229
229
230
+ const parseInputValue = ( value : string ) : any => {
231
+ if ( typeof value !== 'string' ) {
232
+ return value
233
+ }
234
+
235
+ // Remove escape characters (backslashes before special characters)
236
+ // ex: \["a", "b", "c", "d", "e"\]
237
+ let cleanedValue = value
238
+ . replace ( / \\ " / g, '"' ) // \" -> "
239
+ . replace ( / \\ \\ / g, '\\' ) // \\ -> \
240
+ . replace ( / \\ \[ / g, '[' ) // \[ -> [
241
+ . replace ( / \\ \] / g, ']' ) // \] -> ]
242
+ . replace ( / \\ \{ / g, '{' ) // \{ -> {
243
+ . replace ( / \\ \} / g, '}' ) // \} -> }
244
+
245
+ // Try to parse as JSON if it looks like JSON/array
246
+ if (
247
+ ( cleanedValue . startsWith ( '[' ) && cleanedValue . endsWith ( ']' ) ) ||
248
+ ( cleanedValue . startsWith ( '{' ) && cleanedValue . endsWith ( '}' ) )
249
+ ) {
250
+ try {
251
+ return JSON . parse ( cleanedValue )
252
+ } catch ( e ) {
253
+ // If parsing fails, return the cleaned value
254
+ return cleanedValue
255
+ }
256
+ }
257
+
258
+ return cleanedValue
259
+ }
260
+
230
261
if ( newToolNodeInstance . transformNodeInputsToToolArgs ) {
231
262
const defaultParams = newToolNodeInstance . transformNodeInputsToToolArgs ( newNodeData )
232
263
@@ -239,7 +270,7 @@ class Tool_Agentflow implements INode {
239
270
for ( const item of toolInputArgs ) {
240
271
const variableName = item . inputArgName
241
272
const variableValue = item . inputArgValue
242
- toolCallArgs [ variableName ] = variableValue
273
+ toolCallArgs [ variableName ] = parseInputValue ( variableValue )
243
274
}
244
275
245
276
const flowConfig = {
0 commit comments