diff --git a/blocks/blocks/evaluator.ts b/blocks/blocks/evaluator.ts index bafda497d4..ce2d345386 100644 --- a/blocks/blocks/evaluator.ts +++ b/blocks/blocks/evaluator.ts @@ -73,8 +73,12 @@ Description: ${block.description}` .join('\n---\n')} Routing Rules: -- Score greater than or equal to 0.85: Choose success path block +${ + targetBlocks.length === 1 + ? `- Route back to the only available block (${targetBlocks[0].id}) to continue the iteration` + : `- Score greater than or equal to 0.85: Choose success path block - Score less than 0.85: Choose failure path block` +}` : '' return `${basePrompt}${targetBlocksInfo} @@ -83,7 +87,8 @@ Response Format: Return ONLY the destination block ID as a single word, no punctuation or explanation. Example: "2acd9007-27e8-4510-a487-73d3b825e7c1" -Remember: Your response must be ONLY the block ID.` +Remember: Your response must be ONLY the block ID - no additional text, formatting, or explanation. +If there is only one available destination, return that block's ID regardless of the score.` } export const EvaluatorBlock: BlockConfig = { diff --git a/executor/index.ts b/executor/index.ts index ff3526a0d2..4d107f858b 100644 --- a/executor/index.ts +++ b/executor/index.ts @@ -314,7 +314,7 @@ export class Executor { if (executedLoopBlocks.length > 0) { const iterations = loopIterations.get(loopId) || 0 - if (iterations < (loop.maxIterations ?? 5)) { + if (iterations < loop.maxIterations - 1) { // Check if the evaluator chose a block within the loop const evaluatorInLoop = executedLoopBlocks.find((blockId) => { const block = blocks.find((b) => b.id === blockId)