diff --git a/AIClasses/FunctionDefinitions/AIFunctionDefinitions.ts b/AIClasses/FunctionDefinitions/AIFunctionDefinitions.ts index 3679269..5f04c8f 100644 --- a/AIClasses/FunctionDefinitions/AIFunctionDefinitions.ts +++ b/AIClasses/FunctionDefinitions/AIFunctionDefinitions.ts @@ -50,7 +50,7 @@ export abstract class AIFunctionDefinitions { } public static orchestrationAgentDefinitions(): IAIFunctionDefinition[] { - return [CompleteStep, Replan, CancelPlan]; + return [CompleteStep, Replan, CancelPlan, CompletePlan]; } public static planningAgentDefinitions(): IAIFunctionDefinition[] { diff --git a/Services/AIServices/OrchestrationAgent.ts b/Services/AIServices/OrchestrationAgent.ts index 16f7489..3bc8a9b 100644 --- a/Services/AIServices/OrchestrationAgent.ts +++ b/Services/AIServices/OrchestrationAgent.ts @@ -48,6 +48,7 @@ export class OrchestrationAgent extends AIController { callbacks.onPlanUpdate(executionPlan); let currentStepIndex = 0; + let replanRequested = false; for (const [index, step] of executionPlan.executionSteps.entries()) { currentStepIndex = index; callbacks.onPlanStepUpdate(currentStepIndex); @@ -102,11 +103,16 @@ export class OrchestrationAgent extends AIController { role: Role.User, content: `A replan was requested when attempting to execute Step ${index + 1}. Replan context: ${orchestrationResult.replanContext}` })); + replanRequested = true; break; } } - planCompleted = currentStepIndex >= executionPlan.executionSteps.length - 1; + planCompleted = !replanRequested && currentStepIndex >= executionPlan.executionSteps.length - 1; + + if (planCompleted) { + callbacks.onPlanStepUpdate(executionPlan.executionSteps.length); + } } this.debugService?.log("OrchestrationAgent", "Planned workflow completed - requesting summary");