LLMs write reusable code to solve grid-world planning tasks

LLMs write reusable code to solve grid-world planning tasks

Read the full paper on The Gufo

A new framework has large language models generate programs, not one-off answers, to plan in grid-based environments, according to a paper in Royal Society Open Science.

Researchers report that having large language models write executable programs as agent policies, rather than generating a solution for each task instance, improves performance on grid-based planning benchmarks. The paper, published in Royal Society Open Science, describes gains for five of six tested models, with one model, Gemini-2.5-Pro, moving from a negative baseline score to a strongly positive one. The approach also set what the authors call a new state-of-the-art result on the GRASP benchmark.

The method, called iterative programmatic planning (IPP), asks a large language model to write code that maps environment states to action sequences, then refines that code using coarse, task-level feedback rather than per-instance correction.

The authors note that code generation costs more upfront than directly asking a model for a solution: $0.08 per task versus $0.002 per instance for GPT-o3-mini in their tests. They state that this cost is offset because the same code can be reused across many task instances, making the per-instance cost up to 400 times lower on the full GRASP benchmark. The abstract also records that improvement was not universal: one of the six models tested did not benefit from the approach.

For practitioners and students working on automated planning, the paper's main point is practical: generating a reusable, inspectable program can be more efficient than repeated per-instance inference, provided the number of instances is large enough to amortise the higher initial cost. The authors describe the resulting policies as human-readable, which may help with debugging and modification before deployment.

The research

Ashwath Vaithinathan Aravindan, Zhisheng Tang, Mayank Kejriwal (2026). Code-driven planning in grid worlds with large language models. Royal Society Open Science. https://doi.org/10.1098/rsos.260255

Licence: CC BY (terms). The Gufo’s commentary is ours; the paper’s text stays with its authors.

Latest research in Information Technologies