Class LLMDynamicPlanner

java.lang.Object
com.tnsai.planning.llm.LLMDynamicPlanner
All Implemented Interfaces:
com.tnsai.planning.PlannerHandle

public final class LLMDynamicPlanner extends Object implements com.tnsai.planning.PlannerHandle
LLM-powered dynamic planner that uses a language model to decompose natural-language goals into executable step sequences.

Unlike rule-based planners (BackwardChainingPlanner, UtilityAIPlanner), this planner delegates goal decomposition to an LLM, making it suitable for open-ended tasks where actions cannot be predefined via annotations.

Planning Process

  1. Receive goal + available capabilities
  2. Construct prompt with capability descriptions and current state
  3. Call LLM to generate a structured plan (JSON)
  4. Parse response into LLMPlan with executable steps

Usage


 LLMDynamicPlanner planner = LLMDynamicPlanner.builder()
     .llm(client)
     .capabilities(List.of(
         CapabilityDescriptor.of("search", "Search the web"),
         CapabilityDescriptor.of("write_file", "Write content to a file")
     ))
     .build();

 LLMPlan plan = planner.generatePlan("Create a summary of recent AI news");
 

PlannerHandle SPI

This planner also implements PlannerHandle so it can be used as a drop-in replacement in the agent planning pipeline. The SPI methods map goals to LLM plan generation.

Since:
0.3.0
See Also:
  • Method Details

    • builder

      public static LLMDynamicPlanner.Builder builder()
      Creates a new builder.
    • generatePlan

      public LLMPlan generatePlan(String goal)
      Generates a plan for the given natural-language goal.
      Parameters:
      goal - the goal to plan for
      Returns:
      the generated plan
    • generatePlan

      public LLMPlan generatePlan(String goal, Map<String,Object> state)
      Generates a plan for the given goal with current state context.
      Parameters:
      goal - the goal to plan for
      state - current state/context to inform planning
      Returns:
      the generated plan
    • getCapabilities

      public List<CapabilityDescriptor> getCapabilities()
      Returns the configured capabilities.
    • plan

      public List<com.tnsai.planning.PlannerHandle.PlanStep> plan(Map<String,Object> state)
      Specified by:
      plan in interface com.tnsai.planning.PlannerHandle
    • planForGoal

      public List<com.tnsai.planning.PlannerHandle.PlanStep> planForGoal(String goalName, Map<String,Object> state)
      Specified by:
      planForGoal in interface com.tnsai.planning.PlannerHandle
    • execute

      public com.tnsai.planning.PlannerHandle.PlanResult execute(List<com.tnsai.planning.PlannerHandle.PlanStep> steps, Object roleInstance)
      Specified by:
      execute in interface com.tnsai.planning.PlannerHandle
    • isGoalSatisfied

      public boolean isGoalSatisfied(String goalName, Map<String,Object> state)
      Specified by:
      isGoalSatisfied in interface com.tnsai.planning.PlannerHandle
    • getUnsatisfiedGoals

      public List<String> getUnsatisfiedGoals(Map<String,Object> state)
      Specified by:
      getUnsatisfiedGoals in interface com.tnsai.planning.PlannerHandle
    • getRegisteredGoals

      public List<String> getRegisteredGoals()
      Specified by:
      getRegisteredGoals in interface com.tnsai.planning.PlannerHandle