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
@@ -1324,6 +1324,24 @@ export const executeAgentFlow = async ({
}
}
// If the state is persistent, get the state from the previous execution
const startPersistState = nodes.find((node) => node.data.name === 'startAgentflow')?.data.inputs?.startPersistState
if (startPersistState === true && previousExecution) {
const previousExecutionData = (JSON.parse(previousExecution.executionData) as IAgentflowExecutedData[]) ?? []
let previousState = {}
if (Array.isArray(previousExecutionData) && previousExecutionData.length) {
for (const execData of previousExecutionData.reverse()) {
if (execData.data.state) {
previousState = execData.data.state
break
}
}
}
agentflowRuntime.state = previousState
}
// If the start input type is form input, get the form values from the previous execution (form values are persisted in the same session)
if (startInputType === 'formInput' && previousExecution) {
const previousExecutionData = (JSON.parse(previousExecution.executionData) as IAgentflowExecutedData[]) ?? []