Skip to content

Commit 6e2f2df

Browse files
authored
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
1 parent 4af067a commit 6e2f2df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/components/nodes/agentflow/HumanInput/HumanInput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class HumanInput_Agentflow implements INode {
208208
humanInputDescription = (nodeData.inputs?.humanInputDescription as string) || 'Do you want to proceed?'
209209
const messages = [...pastChatHistory, ...runtimeChatHistory]
210210
// Find the last message in the messages array
211-
const lastMessage = (messages[messages.length - 1] as any).content || ''
211+
const lastMessage = messages.length > 0 ? (messages[messages.length - 1] as any).content || '' : ''
212212
humanInputDescription = `${lastMessage}\n\n${humanInputDescription}`
213213
if (isStreamable) {
214214
const sseStreamer: IServerSideEventStreamer = options.sseStreamer as IServerSideEventStreamer

0 commit comments

Comments
 (0)