Interface IPlanningEngine

Interface for the AgentOS Planning Engine.

The Planning Engine provides sophisticated cognitive capabilities for autonomous agents, including:

  • Goal Decomposition: Break complex goals into manageable subtasks
  • Plan Generation: Create multi-step execution plans with ReAct pattern
  • Self-Correction: Refine plans based on execution feedback
  • Autonomous Loops: Pursue goals with minimal human intervention

Example

// Generate and execute a plan
const engine = new PlanningEngine(llmProvider);
const plan = await engine.generatePlan('Build a REST API', {
strategy: 'plan_and_execute',
maxSteps: 20,
});

for (const step of plan.steps) {
const result = await engine.executeStep(step);
if (!result.success) {
const refined = await engine.refinePlan(plan, {
planId: plan.planId,
stepId: step.stepId,
feedbackType: 'step_failed',
details: result.error!,
severity: 'error',
});
}
}
interface IPlanningEngine {
    generatePlan(goal, context?, options?): Promise<ExecutionPlan>;
    decomposeTask(task, depth?): Promise<TaskDecomposition>;
    validatePlan(plan): Promise<PlanValidationResult>;
    refinePlan(plan, feedback): Promise<ExecutionPlan>;
    reflect(plan, executionState): Promise<ReflectionResult>;
    executeStep(step, context?): Promise<PlanStepResult>;
    runAutonomousLoop(goal, options?): AsyncGenerator<LoopProgress, ExecutionSummary, undefined>;
    saveCheckpoint(plan, state): Promise<string>;
    restoreCheckpoint(checkpointId): Promise<{
        plan: ExecutionPlan;
        state: ExecutionState;
    }>;
    getExecutionState(planId): null | ExecutionState;
}

Implemented by

Methods

  • Generates a multi-step execution plan from a high-level goal.

    Parameters

    • goal: string

      The high-level goal to achieve

    • Optional context: PlanningContext

      Additional context for planning

    • Optional options: PlanningOptions

      Planning configuration options

    Returns Promise<ExecutionPlan>

    Generated execution plan

    Example

    const plan = await engine.generatePlan(
    'Analyze customer feedback and generate a report',
    { domainContext: 'E-commerce platform' },
    { strategy: 'react', maxSteps: 15 }
    );