From 126808b62a4f5337334cf2050637ac0133aebfe0 Mon Sep 17 00:00:00 2001 From: Aaron McIntyre Date: Wed, 27 Nov 2024 15:27:49 -0800 Subject: [PATCH] Fix 'label' undefined errors for sequential agents (#3585) Fix 'label' undefined errors Commit adds some optional chaining around 2 reads of 'label' property. --- packages/server/src/utils/buildAgentGraph.ts | 2 +- packages/server/src/utils/buildChatflow.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/utils/buildAgentGraph.ts b/packages/server/src/utils/buildAgentGraph.ts index 3b9c94d2d43..c0e8d7a60dc 100644 --- a/packages/server/src/utils/buildAgentGraph.ts +++ b/packages/server/src/utils/buildAgentGraph.ts @@ -325,7 +325,7 @@ export const buildAgentGraph = async ( // Send loading next agent indicator if (reasoning.next && reasoning.next !== 'FINISH' && reasoning.next !== 'END') { if (sseStreamer) { - sseStreamer.streamNextAgentEvent(chatId, mapNameToLabel[reasoning.next].label || reasoning.next) + sseStreamer.streamNextAgentEvent(chatId, mapNameToLabel[reasoning.next]?.label || reasoning.next) } } } diff --git a/packages/server/src/utils/buildChatflow.ts b/packages/server/src/utils/buildChatflow.ts index 61a69325bac..dd85dc98b93 100644 --- a/packages/server/src/utils/buildChatflow.ts +++ b/packages/server/src/utils/buildChatflow.ts @@ -218,7 +218,7 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals /*** Get session ID ***/ const memoryNode = findMemoryNode(nodes, edges) - const memoryType = memoryNode?.data.label + const memoryType = memoryNode?.data?.label let sessionId = getMemorySessionId(memoryNode, incomingInput, chatId, isInternal) /*** Get Ending Node with Directed Graph ***/