Bugfix/Array Input Variables (#5196)

- Replace manual template variable processing in multiple components with a new utility function `processTemplateVariables`.
This commit is contained in:
Henry Heng
2025-09-12 14:42:34 +01:00
committed by GitHub
parent 736c2b11a1
commit 4987a2880d
9 changed files with 199 additions and 81 deletions
@@ -1,5 +1,6 @@
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams, IServerSideEventStreamer } from '../../../src/Interface'
import { updateFlowState } from '../utils'
import { processTemplateVariables } from '../../../src/utils'
import { Tool } from '@langchain/core/tools'
import { ARTIFACTS_PREFIX, TOOL_ARGS_PREFIX } from '../../../src/agents'
import zodToJsonSchema from 'zod-to-json-schema'
@@ -330,14 +331,7 @@ class Tool_Agentflow implements INode {
sseStreamer.streamTokenEvent(chatId, toolOutput)
}
// Process template variables in state
if (newState && Object.keys(newState).length > 0) {
for (const key in newState) {
if (newState[key].toString().includes('{{ output }}')) {
newState[key] = newState[key].replaceAll('{{ output }}', toolOutput)
}
}
}
newState = processTemplateVariables(newState, toolOutput)
const returnOutput = {
id: nodeData.id,