Introduction
Large Language Models (LLMs) have demonstrated remarkable common-sense reasoning capabilities, yet they frequently struggle with long-horizon planning tasks that require precise, multi-step execution. A recent shift toward "code-augmented planning"—where LLMs generate Python scripts to solve problems—aims to leverage the structural advantages of programming. However, traditional code-based planning faces significant hurdles: a "soft reasoning" gap where code fails at subjective tasks, a "bottom-up rigidity" that requires anticipating all edge cases upfront, and the inherent risk of coding bugs that crash one-shot scripts.
To address these challenges, researchers have introduced REPL-Plan, a framework that makes the planning process interactive and top-down. By allowing models to prototype plans line-by-line and handle errors dynamically, REPL-Plan bridges the gap between structured code and flexible natural language reasoning.
Methodology: The LLM-REPL Framework
The core of REPL-Plan is the LLM-REPL environment. Unlike a standard code interpreter, this environment is designed for interactive planning through three key mechanisms:
- Iterative Execution: The LLM writes and executes code line-by-line, receiving immediate feedback from the environment (e.g., "You are now in the kitchen"). This allows for real-time adjustments.
- Recursive Spawning: When faced with a complex sub-task, the LLM can "spawn" a child REPL. This child environment focuses exclusively on the sub-task, maintaining its own state and history before returning the result to the parent.
- Dynamic Adaptation: The REPL environment allows the model to catch syntax or logic errors immediately. Instead of restarting the entire task, the model can simply write a corrective line of code.
This top-down, divide-and-conquer workflow allows high-level logic (like loops) to be handled by the main REPL, while child REPLs manage the "fuzzy" details of interpreting specific observations or web pages.
Evaluation and Results
REPL-Plan was evaluated across three diverse environments: ALFWorld (household simulator), WebShop (e-commerce navigation), and a new Real-World Web benchmark featuring live, complex websites like BestBuy and Dell.
The framework established new state-of-the-art performance across these benchmarks:
- ALFWorld: Achieved a 97.0% success rate, surpassing previous leading methods like THREAD (95.5%) and ReAct (53.7%).
- WebShop: In complex scenarios involving 10 pages of search results, REPL-Plan reached a 52% success rate, more than doubling the performance of THREAD (21%).
- Real-World Web: On complex tasks, REPL-Plan achieved 39.6% of the expert score, significantly outperforming ReAct (17.6%) while THREAD failed to complete any tasks.
Discussion and Key Insights
REPL-Plan's success stems from several architectural advantages. By adopting a top-down approach, the LLM can call functions that don't yet exist; the system simply spawns a new REPL to "become" that function on the fly. Furthermore, using code as a state compressor helps manage massive text observations in web environments, preventing the LLM's context window from becoming overwhelmed. Finally, the interactivity acts as a safety net, allowing the model to self-correct even when provided with imperfect demonstrations.
Despite its strengths, the system has limitations. Writing code for every action can be inefficient for trivial tasks. There is also a risk of the LLM generating infinite loops, requiring robust halting mechanisms. Future work will focus on improving efficiency and moving toward zero-shot planning for entirely new domains.
Conclusion
REPL-Plan represents a significant step forward in code-augmented planning. By combining the structural power of programming with the recursive flexibility of LLM-driven sub-tasks, it enables agents to navigate complex, long-horizon environments with unprecedented reliability and success.
Summary updated