Bugfix/AgentflowV2 State (#4512)

* add persistence state, http node variables, custom function flow state

* update marketplace templates
This commit is contained in:
Henry Heng
2025-05-27 18:01:39 +01:00
committed by GitHub
parent 572fb31a1c
commit 01dab4365a
15 changed files with 177 additions and 16 deletions
@@ -18,7 +18,7 @@ class Start_Agentflow implements INode {
constructor() {
this.label = 'Start'
this.name = 'startAgentflow'
this.version = 1.0
this.version = 1.1
this.type = 'Start'
this.category = 'Agent Flows'
this.description = 'Starting point of the agentflow'
@@ -153,6 +153,13 @@ class Start_Agentflow implements INode {
optional: true
}
]
},
{
label: 'Persist State',
name: 'startPersistState',
type: 'boolean',
description: 'Persist the state in the same session',
optional: true
}
]
}
@@ -161,6 +168,7 @@ class Start_Agentflow implements INode {
const _flowState = nodeData.inputs?.startState as string
const startInputType = nodeData.inputs?.startInputType as string
const startEphemeralMemory = nodeData.inputs?.startEphemeralMemory as boolean
const startPersistState = nodeData.inputs?.startPersistState as boolean
let flowStateArray = []
if (_flowState) {
@@ -176,6 +184,13 @@ class Start_Agentflow implements INode {
flowState[state.key] = state.value
}
const runtimeState = options.agentflowRuntime?.state as ICommonObject
if (startPersistState === true && runtimeState && Object.keys(runtimeState).length) {
for (const state in runtimeState) {
flowState[state] = runtimeState[state]
}
}
const inputData: ICommonObject = {}
const outputData: ICommonObject = {}
@@ -202,6 +217,10 @@ class Start_Agentflow implements INode {
outputData.ephemeralMemory = true
}
if (startPersistState) {
outputData.persistState = true
}
const returnOutput = {
id: nodeData.id,
name: this.name,