Fixes state interpolation when using {{ output }} (#5039)

* Fixes the lossy-replace when a new state assignment contains the {{ output }} variable

* Replaces replace with replaceAll

---------

Co-authored-by: Corentin <corentin.hoareau@sogeti.com>
This commit is contained in:
corentin-hoareau 2025-08-08 16:08:59 +02:00 committed by GitHub
parent fa15b6873d
commit bbcfb5ab63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 5 additions and 5 deletions

View File

@ -1081,7 +1081,7 @@ class Agent_Agentflow implements INode {
if (newState && Object.keys(newState).length > 0) {
for (const key in newState) {
if (newState[key].toString().includes('{{ output }}')) {
newState[key] = finalResponse
newState[key] = newState[key].replaceAll('{{ output }}', finalResponse)
}
}
}

View File

@ -194,7 +194,7 @@ class CustomFunction_Agentflow implements INode {
if (newState && Object.keys(newState).length > 0) {
for (const key in newState) {
if (newState[key].toString().includes('{{ output }}')) {
newState[key] = finalOutput
newState[key] = newState[key].replaceAll('{{ output }}', finalOutput)
}
}
}

View File

@ -225,7 +225,7 @@ class ExecuteFlow_Agentflow implements INode {
if (newState && Object.keys(newState).length > 0) {
for (const key in newState) {
if (newState[key].toString().includes('{{ output }}')) {
newState[key] = resultText
newState[key] = newState[key].replaceAll('{{ output }}', resultText)
}
}
}

View File

@ -201,7 +201,7 @@ class Retriever_Agentflow implements INode {
if (newState && Object.keys(newState).length > 0) {
for (const key in newState) {
if (newState[key].toString().includes('{{ output }}')) {
newState[key] = finalOutput
newState[key] = newState[key].replaceAll('{{ output }}', finalOutput)
}
}
}

View File

@ -334,7 +334,7 @@ class Tool_Agentflow implements INode {
if (newState && Object.keys(newState).length > 0) {
for (const key in newState) {
if (newState[key].toString().includes('{{ output }}')) {
newState[key] = toolOutput
newState[key] = newState[key].replaceAll('{{ output }}', toolOutput)
}
}
}