From 6e2f2df269594158225f84f5221c0404f4dc80e4 Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Fri, 12 Sep 2025 19:31:47 +0100 Subject: [PATCH] Bugfix/Human Input As First Node (#5202) Updated logic to ensure that the last message is retrieved safely, preventing potential errors when the messages array is empty.for Human Input Node --- packages/components/nodes/agentflow/HumanInput/HumanInput.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/nodes/agentflow/HumanInput/HumanInput.ts b/packages/components/nodes/agentflow/HumanInput/HumanInput.ts index 6fa388e26..8d5818ff3 100644 --- a/packages/components/nodes/agentflow/HumanInput/HumanInput.ts +++ b/packages/components/nodes/agentflow/HumanInput/HumanInput.ts @@ -208,7 +208,7 @@ class HumanInput_Agentflow implements INode { humanInputDescription = (nodeData.inputs?.humanInputDescription as string) || 'Do you want to proceed?' const messages = [...pastChatHistory, ...runtimeChatHistory] // Find the last message in the messages array - const lastMessage = (messages[messages.length - 1] as any).content || '' + const lastMessage = messages.length > 0 ? (messages[messages.length - 1] as any).content || '' : '' humanInputDescription = `${lastMessage}\n\n${humanInputDescription}` if (isStreamable) { const sseStreamer: IServerSideEventStreamer = options.sseStreamer as IServerSideEventStreamer