Learning When to Plan: Efficiently Allocating Test-Time Compute for LLM Agents

Davide Paglieri, Bartłomiej Cupiał, Jonathan Cook, Ulyana Piterbarg, Jens Tuyls, Edward Grefenstette, Jakob Nicolaus Foerster, Jack Parker-Holder, Tim Rocktäschel

TL;DR

Existing LLM agents either plan at every single step (which is computationally expensive and causes behavioral instability) or never plan at all. This paper introduces a framework and a two-stage training pipeline (SFT + RL) that teaches a single monolithic LLM to dynamically decide when to allocate test-time compute for planning. The resulting 8B parameter agent outperforms a 70B zero-shot baseline while using 85% fewer tokens.

What Problem Does This Paper Address?

Recent breakthroughs in LLM reasoning (like OpenAI's o1 and DeepSeek-R1) show that scaling "test-time compute"—giving models more tokens to think before they respond—dramatically improves performance on single-turn tasks like math and coding. However, extending this to sequential, long-horizon agentic tasks remains a challenge.

Popular agent frameworks like ReAct enforce a rigid "always-plan" strategy, prompting the LLM to output a reasoning trace before every single action. The authors demonstrate that this brute-force approach is not only computationally wasteful but actively harms performance. In complex environments, excessive replanning introduces behavioral instability, such as "overthinking," backtracking, and shifting between subgoals too frequently. Conversely, a "never-plan" strategy severely limits the agent's capacity for strategic reasoning. The core challenge is teaching an agent when it is worth spending computational resources to update its plan.

Methods

The authors address this by formalizing the cost-benefit trade-offs of planning within a Partially-Observable Markov Decision Process (POMDP) framework. They model the decision to plan as balancing the Planning Advantage (the expected improvement in future rewards from a new plan) against the Planning Cost (token costs, latency, and behavioral noise/instability).

Instead of using a separate mediator or gating network, the authors implement this entirely within a single monolithic LLM. The decision to plan is made implicitly: if the model generates a <plan> token, it enters a planning mode; otherwise, it immediately outputs an action.

Dynamic Planning Agent Architecture

To train the agent, they propose a simple two-stage pipeline:

  1. Supervised Fine-Tuning (SFT) Priming: They generate a diverse dataset of trajectories using a larger teacher model (Llama-3.3-70B) prompted with 16 distinct planning styles (e.g., milestone-focused, short-term sequence, information-gap) executed at randomized intervals. Fine-tuning on this data primes the model with the structural capability to generate and follow plans.
  2. Reinforcement Learning (RL) Fine-Tuning: They use Proximal Policy Optimization (PPO) to optimize the agent's parameters. Crucially, they add a token-length penalty to the reward function ($R_{task} - d_t \cdot C_{tokens}$), forcing the model to autonomously learn the optimal trade-off between planning and action execution.

Datasets

The approach was evaluated on two distinct environments:

  • Partially-Observable Graph Search (POGS): A custom-designed synthetic environment where agents navigate procedurally generated graphs with limited local visibility. This environment was specifically built to isolate planning under uncertainty and measure exploration efficiency via backtracking statistics.
  • Crafter: A challenging, Minecraft-inspired 2D grid-world benchmark that requires multi-scale planning for survival, resource management, and crafting across long horizons.
  • TextWorld: Used in zero-shot extension experiments to verify the generality of the findings.

Key Insights and Ideas

  • The "Goldilocks" Zone: Zero-shot experiments across multiple model architectures (Llama, Gemini) revealed a non-monotonic relationship between planning frequency and success. Performance peaks at intermediate planning frequencies; planning too much or too little degrades success rates.
  • Overthinking Causes Backtracking: In the POGS environment, the "always-plan" strategy led to the highest rate of backtracking, proving that excessive reasoning causes agents to constantly change their minds and oscillate between states.
  • SFT Priming is a Hard Prerequisite: Base models trained with RL alone completely fail to learn effective dynamic planning, often performing worse than non-planning baselines. SFT provides the essential structural scaffolding.
  • Plans as Regularizers: Including natural language plans in the SFT data resulted in lower KL divergence from the base model during training, suggesting that textual reasoning stabilizes the fine-tuning process and mitigates catastrophic forgetting.
  • Human-in-the-Loop Steerability: Once trained via RL, the dynamic planning agent becomes highly steerable. It can successfully ingest and execute high-level plans written by humans, unlocking complex behaviors that the agent cannot achieve autonomously.

Key Results

  • Efficiency Gains: The fine-tuned Llama-3.1-8B agent (SFT+RL) achieved a higher reward on Crafter than the much larger Llama-3.3-70B zero-shot baseline (0.387 vs. 0.379) while generating 85% fewer tokens overall.
  • Improved Plan Quality: According to an LLM-as-a-judge evaluation, RL fine-tuning significantly improved the agent's handling of "plan drift." The SFT+RL agent successfully completed its plans 20% of the time (vs. 16% for SFT alone) and adaptively discarded outdated plans 41% of the time (vs. 35% for SFT alone).
  • Solving Crafter: While no autonomous agent fully solved the environment, the human-collaborative setup allowed the SFT+RL agent to successfully mine a diamond—a milestone never achieved in autonomous runs.
Human-Agent Collaboration in Crafter

Limitations and Future Work

While promising, the authors note several limitations:

  • Scale Limitations: Due to computational constraints, fine-tuning experiments were restricted to the 8B parameter scale. How these optimal compute allocation strategies scale with much larger model parameters remains an open question.
  • Domain Diversity: The framework was tested primarily on grid-world and graph-search tasks. Further validation is needed across more diverse agentic domains, such as web navigation or operating system interaction.
  • Algorithmic Integration: Future work could explore more sophisticated, explicit methods for integrating the cost-benefit framework directly into novel RL objectives rather than relying purely on implicit token penalties.

Summary updated

BibTeX
@misc{paglieri2025learning,
  author = {Davide Paglieri and Bartłomiej Cupiał and Jonathan Cook and Ulyana Piterbarg and Jens Tuyls and Edward Grefenstette and Jakob Nicolaus Foerster and Jack Parker-Holder and Tim Rocktäschel},
  title = {{Learning When to Plan: Efficiently Allocating Test-Time Compute for LLM Agents}},
  year = {2025},
  eprint = {2509.03581},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.03581},
}
Figure