Fix Agent node structured output not updating flow state variables (#5548)

Fix Agent state processing for structured output

Updated the Agent class to handle structured output by passing a JSON string instead of a markdown-wrapped response to the `processTemplateVariables` function. This change allows for proper nested property access and resolves string replacement issues with object coercion.
This commit is contained in:
Ahmed Mostafa
2025-12-05 14:37:15 +03:00
committed by GitHub
parent 6fb97cee7f
commit 47de40761f
@@ -1394,7 +1394,9 @@ class Agent_Agentflow implements INode {
}
// Process template variables in state
newState = processTemplateVariables(newState, finalResponse)
const outputForStateProcessing =
isStructuredOutput && typeof response === 'object' ? JSON.stringify(response, null, 2) : finalResponse
newState = processTemplateVariables(newState, outputForStateProcessing)
/**
* Remove the temporarily added image artifact messages before storing