Large Language Models (LLMs) have demonstrated remarkable proficiency in code generation, yet they frequently stumble when faced with the complex logic required for "generalized planning." Unlike classical planning, which seeks a sequence of actions for a specific task, generalized planning requires the creation of a single, robust program capable of solving any problem instance within a given domain, regardless of the number of objects or the environment's layout.
This paper introduces a novel strategy refinement pipeline that addresses the "strategy bottleneck"—the tendency for LLMs to generate logically flawed initial plans that cannot be fixed by simple code-level debugging. By forcing the model to generate and debug structured pseudocode before writing final Python programs, the proposed method achieves 100% success across 12 out of 17 challenging planning benchmarks.
The Strategy Refinement Pipeline
The core of this approach is a multi-stage pipeline that treats strategy generation as a rigorous engineering task. Previous methods often attempted to jump directly from natural language summaries to code, leading to persistent logical errors.
As shown in Figure 1, the process is divided into three distinct phases:
- NL Generation: The system generates natural language summaries of the PDDL (Planning Domain Definition Language) domain and specific tasks.
- Strategy Generation: Instead of vague descriptions, the LLM generates strategies in structured pseudocode. This format serves as a "Goldilocks" medium—more structured than natural language but less syntactically demanding than Python, allowing the model to focus on algorithmic flow.
- Code Generation: Once a strategy is validated, it is translated into a Python program.
Debugging through Reflection
A pivotal innovation in this framework is the use of automated reflection. Before any Python code is written, the LLM is tasked with "manually" solving small example tasks using its own pseudocode. A symbolic validator (VAL) checks these plans. If a plan fails, the LLM is not simply told it is wrong; it is prompted to identify exactly which line of the pseudocode failed and explain the underlying logic error.
This reflection step prevents the model from repeating the same mistakes. By mapping specific logic steps in the pseudocode to blocks of code (as illustrated in Figure 4), the system ensures that the final Python program is grounded in a verified logical foundation. To further improve robustness, the system generates multiple program variants by varying input prompts and selects the version that performs best on debugging tasks.
Key Results and Insights
The researchers evaluated the framework on 17 PDDL domains, including complex benchmarks like BlocksWorld and Logistics. The results highlight several key advantages of the reflection-based pipeline:
- Superior Coverage: The system achieved 100% coverage in 12 of the 17 domains, substantially outperforming previous state-of-the-art LLM methods in 9 domains.
- Efficiency: While symbolic planners (like A*) are effective, they often suffer from exponential search times. The LLM-generated Python programs run in polynomial time, solving massive problems in milliseconds—averaging 40 times faster than standard symbolic planners.
- Cost-Effectiveness: Despite the iterative nature of the pipeline, the maximum cost per domain remained low (approximately $14 USD using GPT-4o), making it a practical alternative to compute-heavy training of specialized models.
Limitations and Future Work
Despite its success, the system still faces challenges. LLMs occasionally hallucinate action semantics, such as forgetting that a vehicle must be at a specific location to perform an unload action. Future iterations could mitigate this by providing "boilerplate" code for action semantics. Additionally, as these programs lack formal proofs of correctness, a hybrid approach—where a symbolic planner acts as a safety net if the Python program fails—remains a promising avenue for future research.
Summary updated