Record Class LLMPlan

java.lang.Object
java.lang.Record
com.tnsai.planning.llm.LLMPlan
Record Components:
goal - the original natural-language goal
steps - ordered list of plan steps
reasoning - overall reasoning/strategy explanation

public record LLMPlan(String goal, List<LLMPlanStep> steps, String reasoning) extends Record
An LLM-generated execution plan.

Contains the ordered steps, overall reasoning, and the original goal. Plans are immutable once created but can be modified via withReorderedSteps(List) or withoutStep(int) for user approval workflows.

Since:
0.3.0
See Also:
  • Constructor Details

    • LLMPlan

      public LLMPlan(String goal, List<LLMPlanStep> steps, String reasoning)
      Creates an instance of a LLMPlan record class.
      Parameters:
      goal - the value for the goal record component
      steps - the value for the steps record component
      reasoning - the value for the reasoning record component
  • Method Details

    • size

      public int size()
      Returns the number of steps in this plan.
    • isEmpty

      public boolean isEmpty()
      Returns true if the plan has no steps.
    • withReorderedSteps

      public LLMPlan withReorderedSteps(List<Integer> newOrder)
      Creates a new plan with steps reordered according to the given indices.
      Parameters:
      newOrder - list of step indices in desired order
      Returns:
      new plan with reordered steps
      Throws:
      IndexOutOfBoundsException - if any index is invalid
    • withoutStep

      public LLMPlan withoutStep(int stepIndex)
      Creates a new plan with the step at the given index removed.
      Parameters:
      stepIndex - the step to remove
      Returns:
      new plan without the specified step
      Throws:
      IndexOutOfBoundsException - if index is invalid
    • remainingFrom

      public LLMPlan remainingFrom(int fromIndex)
      Creates a new plan with only the remaining steps starting from the given index.
      Parameters:
      fromIndex - start index (inclusive)
      Returns:
      new plan with remaining steps
    • toDisplayString

      public String toDisplayString()
      Formats the plan for display to users.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • goal

      public String goal()
      Returns the value of the goal record component.
      Returns:
      the value of the goal record component
    • steps

      public List<LLMPlanStep> steps()
      Returns the value of the steps record component.
      Returns:
      the value of the steps record component
    • reasoning

      public String reasoning()
      Returns the value of the reasoning record component.
      Returns:
      the value of the reasoning record component