Modify evaluator to just loop back and forth if there is only one destination in loop

This commit is contained in:
Waleed Latif
2025-02-12 12:08:46 -08:00
parent 11cbd1dab2
commit ec2150ac3b
2 changed files with 8 additions and 3 deletions
+7 -2
View File
@@ -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<EvaluatorResponse> = {
+1 -1
View File
@@ -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)