Improved Generalized Planning with LLMs through Strategy Refinement and Reflection
This paper presents an improved framework for LLM-based generalized planning that enhances plan quality by introducing pseudocode-based strategy refinement with automatic debugging, incorporating reflection to diagnose failures, and generating multiple program variants, achieving an average 82% coverage across 17 benchmark domains.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are trying to teach a very smart, but slightly literal-minded, robot how to solve a specific type of puzzle. Let's say the puzzle is Logistics: moving packages from one city to another using trucks and planes.
In the past, researchers tried to ask the robot (a Large Language Model, or LLM) to solve every single puzzle instance one by one. It was like asking the robot, "How do I move this one box?" then "How do I move this other box?" It was slow, expensive, and the robot often got confused when the puzzle got bigger.
Then, a new idea came along: Generalized Planning. Instead of solving one puzzle, we ask the robot to write a master recipe (a computer program) that can solve any logistics puzzle, no matter how many boxes or cities are involved.
However, the first attempts at this had a major flaw. It was like asking the robot to write a recipe, but the robot would just give you a vague paragraph like, "Cook the food until it's done." If the robot misunderstood the vague instructions, the resulting recipe would be garbage, and the food would burn. The researchers couldn't fix the recipe easily because they were trying to debug the final code directly, which is like trying to fix a car engine while the car is still driving.
This paper introduces a three-step upgrade to fix this, making the robot much better at writing these master recipes. Here is how it works, using simple analogies:
1. The "Blueprint" Phase (Pseudocode Strategy)
Instead of asking the robot to jump straight into writing complex code (the final recipe), the researchers first ask it to draw a blueprint or a flowchart using simple, structured English (called pseudocode).
- The Old Way: "Write a program to move packages." -> Robot writes code immediately.
- The New Way: "First, write a step-by-step list of instructions in plain English, like a flowchart."
- Example: "1. Find the package. 2. Is it in the same city as the goal? If yes, drive the truck. If no, drive to the airport, fly, then drive again."
Why this helps: It's much easier to spot a logic error in a simple list of steps than in a wall of computer code. It's like checking a map before you start driving, rather than trying to fix your GPS while you're stuck in traffic.
2. The "Mock Trial" Phase (Strategy Validation & Reflection)
Once the robot has its blueprint (the pseudocode), the researchers don't just trust it. They put it through a mock trial.
- The Process: They take a few small, easy puzzles and ask the robot: "Okay, follow your blueprint to solve this specific puzzle."
- The Catch: The robot isn't actually running code yet; it's just simulating the plan. If the plan fails (e.g., the robot tries to load a package onto a plane while it's still inside a truck), the system catches the error.
- The "Reflection" Step: This is the magic sauce. Instead of just saying "Error," the system asks the robot to think about why it failed.
- System: "You tried to load the package onto the plane, but the package was still in the truck. Why did your blueprint miss this step?"
- Robot: "Oh, I see! My blueprint forgot to say 'Unload the package from the truck' before loading it onto the plane."
- Robot: "I will fix the blueprint now."
This is like a student taking a practice test, getting a question wrong, and then being asked to explain why they got it wrong before trying again. This "reflection" prevents the robot from making the same mistake twice.
3. The "Tasting Panel" Phase (Multiple Code Versions)
Finally, once the blueprint is perfect, the robot writes the actual computer code. But the researchers don't just accept the first draft.
- The Process: They ask the robot to write three or five different versions of the code based on the same perfect blueprint.
- The Selection: They run all these versions on the test puzzles and pick the one that works best.
Why this helps: Sometimes, even with a good blueprint, a chef might chop an onion slightly differently. By generating multiple versions, you ensure you get the best possible "dish."
The Results: A Super-Recipe
The researchers tested this new method on 17 different types of puzzles (from moving trucks to flying satellites) using four different AI models.
- The Old Method: The robot got about 37% of the puzzles right on average.
- The New Method: The robot got 82% of the puzzles right.
Even more impressively, the "recipes" the robot wrote were general. They didn't just work for the specific puzzles the robot saw during training; they worked for puzzles with more packages, more cities, and more complexity than the robot had ever seen before.
Summary
Think of this paper as teaching an AI to be a better architect before it becomes a builder.
- Don't build yet: First, draw a detailed, step-by-step blueprint (Pseudocode).
- Test the blueprint: Run a simulation to find holes in the plan.
- Reflect and fix: Ask the AI to explain its mistakes and redraw the blueprint.
- Build and choose: Generate a few different buildings based on the fixed blueprint and pick the strongest one.
By slowing down to think and reflect before writing the final code, the AI creates much more reliable, powerful, and general solutions.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.