From ac28e09b513b354c92300a13844f4a66905cd5ff Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 12 Feb 2025 11:24:51 -0800 Subject: [PATCH] Added maxIterations to serialized loops, executor now uses provided max iterations for each loop from workflow store --- executor/index.ts | 3 +-- serializer/types.ts | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/executor/index.ts b/executor/index.ts index 1906b3bc25..ff3526a0d2 100644 --- a/executor/index.ts +++ b/executor/index.ts @@ -88,7 +88,6 @@ export class Executor { */ private async executeInParallel(context: ExecutionContext): Promise { const { blocks, connections } = this.workflow - const MAX_ITERATIONS = 2 // Add safety limit for loops // Track iterations per loop const loopIterations = new Map() @@ -315,7 +314,7 @@ export class Executor { if (executedLoopBlocks.length > 0) { const iterations = loopIterations.get(loopId) || 0 - if (iterations < MAX_ITERATIONS) { + if (iterations < (loop.maxIterations ?? 5)) { // Check if the evaluator chose a block within the loop const evaluatorInLoop = executedLoopBlocks.find((blockId) => { const block = blocks.find((b) => b.id === blockId) diff --git a/serializer/types.ts b/serializer/types.ts index 7bc20749b8..a33efb60df 100644 --- a/serializer/types.ts +++ b/serializer/types.ts @@ -42,4 +42,5 @@ export interface SerializedBlock { export interface SerializedLoop { id: string nodes: string[] + maxIterations: number }