Updated logic to ensure that the last message is retrieved safely, preventing potential errors when the messages array is empty.for Human Input Node

This commit is contained in:
Henry 2025-09-12 19:19:45 +01:00
parent 4af067a444
commit ab044250b4
1 changed files with 1 additions and 1 deletions

View File

@ -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