Skip to content

Commit 47de407

Browse files
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.
1 parent 6fb97ce commit 47de407

File tree

1 file changed

+3
-1
lines changed
  • packages/components/nodes/agentflow/Agent

1 file changed

+3
-1
lines changed

packages/components/nodes/agentflow/Agent/Agent.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,9 @@ class Agent_Agentflow implements INode {
13941394
}
13951395

13961396
// Process template variables in state
1397-
newState = processTemplateVariables(newState, finalResponse)
1397+
const outputForStateProcessing =
1398+
isStructuredOutput && typeof response === 'object' ? JSON.stringify(response, null, 2) : finalResponse
1399+
newState = processTemplateVariables(newState, outputForStateProcessing)
13981400

13991401
/**
14001402
* Remove the temporarily added image artifact messages before storing

0 commit comments

Comments
 (0)