From 21767d2eee259d024a8bd580adba5b950a65605d Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Thu, 17 Apr 2025 15:04:06 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=EF=B8=8F=20Fix=20maximum=20callsta?= =?UTF-8?q?ck=20size=20issue=20from=20setVariableHistory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/bot-engine/src/walkFlowForward.ts | 30 ++++++++-------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/packages/bot-engine/src/walkFlowForward.ts b/packages/bot-engine/src/walkFlowForward.ts index 0cee37256..f8d7f4d04 100644 --- a/packages/bot-engine/src/walkFlowForward.ts +++ b/packages/bot-engine/src/walkFlowForward.ts @@ -83,11 +83,12 @@ export const walkFlowForward = async ( isOffDefaultPath: nextEdge?.isOffDefaultPath ?? false, }); newSessionState = nextGroupResponse.newSessionState; + if (nextGroupResponse.visitedEdge) + visitedEdges.push(nextGroupResponse.visitedEdge); if (!nextGroupResponse?.group) break; const executionResponse = await executeGroup(nextGroupResponse.group, { version, state: newSessionState, - visitedEdges, setVariableHistory, skipFirstMessageBubble, timeoutStartTime, @@ -96,10 +97,8 @@ export const walkFlowForward = async ( }); if (executionResponse.logs) logs.push(...executionResponse.logs); newSessionState = executionResponse.newSessionState; - if (executionResponse.visitedEdges) - visitedEdges.push(...executionResponse.visitedEdges); - if (executionResponse.setVariableHistory) - setVariableHistory.push(...executionResponse.setVariableHistory); + if (executionResponse.newSetVariableHistoryItems) + setVariableHistory.push(...executionResponse.newSetVariableHistoryItems); if (executionResponse.messages) messages.push(...executionResponse.messages); if (executionResponse.input) input = executionResponse.input; @@ -133,7 +132,6 @@ type ContextProps = { sessionStore: SessionStore; currentLastBubbleId?: string; skipFirstMessageBubble?: boolean; - visitedEdges: Prisma.VisitedEdge[]; setVariableHistory: SetVariableHistoryItem[]; timeoutStartTime?: number; textBubbleContentFormat: "richText" | "markdown"; @@ -141,8 +139,7 @@ type ContextProps = { export type ExecuteGroupResponse = ContinueChatResponse & { newSessionState: SessionState; - setVariableHistory: SetVariableHistoryItem[]; - visitedEdges: Prisma.VisitedEdge[]; + newSetVariableHistoryItems: SetVariableHistoryItem[]; updatedTimeoutStartTime?: number; nextEdge?: { id: string; @@ -156,7 +153,6 @@ const executeGroup = async ( version, state, sessionStore, - visitedEdges, setVariableHistory, currentLastBubbleId, skipFirstMessageBubble, @@ -170,7 +166,7 @@ const executeGroup = async ( let nextEdge; let lastBubbleBlockId: string | undefined = currentLastBubbleId; let updatedTimeoutStartTime = timeoutStartTime; - + const newSetVariableHistoryItems: SetVariableHistoryItem[] = []; let newSessionState = state; let index = -1; @@ -216,8 +212,7 @@ const executeGroup = async ( }, clientSideActions, logs, - visitedEdges, - setVariableHistory, + newSetVariableHistoryItems, }; } @@ -238,8 +233,7 @@ const executeGroup = async ( }, clientSideActions, logs, - visitedEdges, - setVariableHistory, + newSetVariableHistoryItems, }; const logicOrIntegrationExecutionResponse = ( isLogicBlock(block) @@ -282,7 +276,7 @@ const executeGroup = async ( }, }; else - setVariableHistory.push( + newSetVariableHistoryItems.push( ...logicOrIntegrationExecutionResponse.newSetVariableHistory, ); } @@ -333,8 +327,7 @@ const executeGroup = async ( }, clientSideActions, logs, - visitedEdges, - setVariableHistory, + newSetVariableHistoryItems, }; } } @@ -357,8 +350,7 @@ const executeGroup = async ( clientSideActions, updatedTimeoutStartTime, logs, - visitedEdges, - setVariableHistory, + newSetVariableHistoryItems, }; };