Introduction
Large Language Models (LLMs) like GPT-4 are increasingly being evaluated for their potential in robotics and autonomous agents. However, a significant bottleneck remains: "long-horizon planning." This refers to the ability to think many steps ahead under strict constraints to reach a distant goal. While LLMs often show flashes of brilliance in logical reasoning, their ability to navigate complex spatial environments is less understood. This paper investigates whether GPT-4 can maintain a "mental map" of a 2D environment or if it merely stumbles toward a solution.
Challenging the Status Quo: A New Benchmark
Existing benchmarks for path planning often utilize small grids (e.g., 6x6) with randomly scattered obstacles. In such simple settings, an LLM might find a solution by luck rather than through genuine spatial reasoning. To address this, the authors introduced a new synthetic benchmark consisting of 25x25 grids with three distinct geometric layouts:
- Rectangular Blocks: Irregular obstacles creating narrow, diverse passages.
- Square Mazes: Concentric squares with a single opening on each side, requiring a specific inward or outward trajectory.
- Zig-zag Mazes: Horizontal walls that force the agent to make frequent, sharp turns.
The dataset includes both In-distribution (IID) instances with short paths and Out-of-distribution (OOD) instances with significantly longer paths to test the limits of the model's planning horizon.
Methodology: Representations and Prompting
The study evaluated GPT-4 using three different ways of describing the environment (Representations) and three different ways of requesting a plan (Prompting Methodologies).
Task Representations
- Naive Enumeration: Listing every single (x, y) coordinate that contains an obstacle.
- Code Representation: Describing the environment using Python code logic (e.g., using
forloops to define walls). This leverages GPT-4’s extensive training on code and is significantly more token-efficient. - Grid Representation: Providing a 2D string of numbers (0 for free space, 1 for obstacle, 2 for start, 3 for goal).
Prompting Methodologies
- Naive Few-shot: Providing five examples of solved paths in the prompt.
- Planning with Feedback: An iterative approach where an "Executor" informs the LLM if it hit a wall or moved off-grid, allowing for up to seven trials.
- Task Decomposition: Breaking a long path into smaller sub-goals (5 steps or fewer) and asking the LLM to solve them sequentially.
Key Insights
Code as the Language of Logic
GPT-4 performed best when the environment was described as Python code. This representation was not only more efficient—reducing input tokens for a square maze from 21,360 to just 4,336—but it also seemed to better "unlock" the model's internal reasoning capabilities compared to natural language or raw coordinate lists.
The 2D Blind Spot
Despite being the most intuitive representation for humans, the Grid Representation was a failure for GPT-4. Because LLMs process text sequentially (one token after another), they struggle to reconstruct the vertical relationships in a 2D block of text. This leads to "hallucinated" paths where the model believes it is moving through free space when it is actually crossing a wall.
Geometry vs. Distance
The difficulty of a planning task is determined more by the complexity of the path than the literal distance to the goal. GPT-4’s performance dropped most sharply in zig-zag mazes. These environments require frequent, precise turns, proving that spatial reasoning is a distinct and more difficult challenge for the model than simple temporal sequencing.
Results and the "Optimality Gap"
While Task Decomposition emerged as the most effective strategy for long-horizon tasks—maintaining a high success rate in rectangular environments where other methods failed—a major issue remained: the Optimality Gap.
Across almost all tests, the percentage of paths that were the shortest possible (the Optimal Rate) was near zero. Even when GPT-4 successfully reached the goal, it often produced "backtracking" behavior—moving away from the goal and then returning. In many failed cases, the model actually moved the agent further from the goal than its starting position, highlighting a fundamental failure in basic spatial orientation.
Conclusion
The study confirms that LLMs are not yet ready to serve as end-to-end planners for complex robotics. They lack a true global topology of the maps they navigate. However, the success of Task Decomposition suggests a promising path forward: hybrid systems. In these systems, LLMs are used for high-level task understanding and decomposition, while the low-level, coordinate-perfect pathfinding is left to classical algorithms like A*.
Summary updated