Package com.tnsai.planning.llm
Class LLMDynamicPlanner
java.lang.Object
com.tnsai.planning.llm.LLMDynamicPlanner
- All Implemented Interfaces:
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
- Receive goal + available capabilities
- Construct prompt with capability descriptions and current state
- Call LLM to generate a structured plan (JSON)
- Parse response into
LLMPlanwith 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:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.tnsai.planning.PlannerHandle
com.tnsai.planning.PlannerHandle.Factory, com.tnsai.planning.PlannerHandle.PlanResult, com.tnsai.planning.PlannerHandle.PlanStep, com.tnsai.planning.PlannerHandle.StepResult -
Method Summary
Modifier and TypeMethodDescriptionstatic LLMDynamicPlanner.Builderbuilder()Creates a new builder.com.tnsai.planning.PlannerHandle.PlanResultgeneratePlan(String goal) Generates a plan for the given natural-language goal.generatePlan(String goal, Map<String, Object> state) Generates a plan for the given goal with current state context.Returns the configured capabilities.getUnsatisfiedGoals(Map<String, Object> state) booleanisGoalSatisfied(String goalName, Map<String, Object> state) List<com.tnsai.planning.PlannerHandle.PlanStep> List<com.tnsai.planning.PlannerHandle.PlanStep> planForGoal(String goalName, Map<String, Object> state)
-
Method Details
-
builder
Creates a new builder. -
generatePlan
Generates a plan for the given natural-language goal.- Parameters:
goal- the goal to plan for- Returns:
- the generated plan
-
generatePlan
Generates a plan for the given goal with current state context.- Parameters:
goal- the goal to plan forstate- current state/context to inform planning- Returns:
- the generated plan
-
getCapabilities
Returns the configured capabilities. -
plan
- Specified by:
planin interfacecom.tnsai.planning.PlannerHandle
-
planForGoal
public List<com.tnsai.planning.PlannerHandle.PlanStep> planForGoal(String goalName, Map<String, Object> state) - Specified by:
planForGoalin interfacecom.tnsai.planning.PlannerHandle
-
execute
public com.tnsai.planning.PlannerHandle.PlanResult execute(List<com.tnsai.planning.PlannerHandle.PlanStep> steps, Object roleInstance) - Specified by:
executein interfacecom.tnsai.planning.PlannerHandle
-
isGoalSatisfied
- Specified by:
isGoalSatisfiedin interfacecom.tnsai.planning.PlannerHandle
-
getUnsatisfiedGoals
- Specified by:
getUnsatisfiedGoalsin interfacecom.tnsai.planning.PlannerHandle
-
getRegisteredGoals
- Specified by:
getRegisteredGoalsin interfacecom.tnsai.planning.PlannerHandle
-