PhGPO: Pheromone-Guided Policy Optimization for Long-Horizon Tool Planning

Yu Li, Guangfeng Cai, Shengtian Yang, Han Luo, Shuo Han, Xu He, Dong Li, Lei Feng

TL;DR

When Large Language Model (LLM) agents tackle complex tasks requiring 10 to 20 sequential tool calls, standard reinforcement learning gets lost in a massive combinatorial maze, quickly forgetting rare "winning paths" by absorbing them implicitly into model weights. Taking a cue from nature's most efficient foragers—ants—this paper introduces PhGPO, a method that leaves explicit digital "pheromone trails" on a graph of tools whenever an agent succeeds. By reinforcing good paths and letting stale ones evaporate, agents learn to chain tools together far more reliably over long horizons.

What Problem Does This Paper Address?

Teaching an LLM to use a single calculator or web search is old news. The real frontier is long-horizon tool planning: chaining together 10 to 20 actions across hundreds of APIs where a single misstep at step two dooms you at step fifteen.

Reinforcement Learning (RL) is the standard way to train agents through trial and error. However, in a massive action space, stumbling upon a completely successful 15-step sequence is vanishingly rare. Worse, when an RL agent does strike gold, it folds that experience implicitly into billions of neural network parameters via a gradient update, leaving no explicit record of the winning sequence. Next time a similar task comes up, the agent essentially has to rediscover the path all over again.

Figure 1: Two-stage pilot experiment with an explicit transition prior for long-horizon tool planning. We distill cross-trajectory transition memory from verified successful tool-use trajectories in an easier stage, then reuse it as a prior for GRPO optimization. Panels (a,b) show higher average return and success rate under matched interaction budgets, (c) fewer steps to the first successful tool-use trajectory, and (d) larger relative gains with longer trajectories.

As the authors show in a pilot study (above), distilling historical successes into an explicit "transition memory" dramatically speeds up path discovery (-26% steps) and yields massive relative gains (+278% at length 7) as tasks grow longer.

Methods

To build this explicit memory, the authors combine standard LLM policy optimization—specifically Group Relative Policy Optimization (GRPO), which learns by comparing groups of generated attempts against each other—with classic Ant Colony Optimization (ACO). Here is what is new in Pheromone-Guided Policy Optimization (PhGPO):

  1. The MCP Tool Graph: Using the Model Context Protocol (MCP), tools are mapped as nodes on a directed graph. Edges represent sequential tool transitions (e.g., WebSearch $\rightarrow$ FetchHTML). Each tool also links to a set of frequent argument-invocation templates, separating which tool to pick from how to call it.
  2. Digital Pheromones: Whenever a trajectory succeeds, PhGPO deposits "pheromones" along the traversed graph edges based on how well the path matched a reference trajectory. Just like real ant trails, these pheromones evaporate over time so the agent isn't trapped by outdated habits early in training. Crucially, PhGPO blends task-agnostic pheromones (globally useful habits) with task-dependent pheromones (retrieved via cosine similarity of task descriptions from an edge memory bank).
  3. Progressive Training Pipeline: If you let a novice agent wander randomly, it won't succeed enough to lay down useful pheromones. PhGPO solves this "cold-start" problem in three phases:
  4. Supervised Warm-up: Basic next-tool prediction so the policy isn't guessing blindly.
  5. Progressive Pheromone Updates: A curriculum starting with short tasks and partial "oracle" (teacher) guidance. As the oracle probability decays, the agent builds up real, policy-driven pheromone trails.
  6. Full-Pheromone Rollouts: The training wheels come off. During GRPO rollout sampling, the LLM's output probabilities are directly reweighted in log-space by the learned pheromone priors.

Datasets

The authors do not introduce new benchmarks, instead evaluating PhGPO on filtered, verified episodes from three existing long-horizon tool-use datasets:

  • Toolathlon: Built on MCP servers featuring hundreds of tools across diverse domains.
  • TRAJECT-Bench: Grounded in executable, production-style APIs.
  • TOUCAN: A large-scale tool-agent dataset synthesized directly from real-world MCP environments.

Key Insights and Ideas

  • Pheromones rescue group-based RL: GRPO relies on contrasting better and worse rollouts within a sampled group. In long-horizon tasks, unguided sampling produces groups where every rollout fails miserably, starving the model of a learning signal. Pheromone-guided sampling nudges rollouts toward plausible paths, restoring meaningful variance within each group.
  • Evaporation isn't optional: Freezing the pheromones or turning off evaporation ($\rho=0$) noticeably hurts performance. As the underlying LLM gets smarter, old shortcuts become suboptimal; evaporation clears away stale statistics.
  • Curriculum bootstraps the colony: Removing the progressive oracle-guided curriculum caused the single biggest performance drop in ablations (-5.48% success rate). You need guided early wins to lay down the initial trails before letting the colony self-organize.

Key Results

Tested on Qwen2.5-7B and Llama3.1-8B backbones (fine-tuned via LoRA), PhGPO outperforms 13 baselines spanning prompting (ReAct), RAG (Gorilla), graph navigation (GTool), and RL (TreeRL, StepTool).

  • Quantitative Gains: With Qwen2.5-7B, PhGPO achieves the highest Task Success Rate (TSR)—judged by GPT-4o on final execution outcomes—across all benchmarks: 20.34% on Toolathlon (vs. 18.91% for TreeRL), 32.18% on TRAJECT-Bench (vs. 28.06% for GTool), and 26.28% on TOUCAN (vs. 20.86% for StepTool). Reference trajectory Match Ratios saw similar ~4–6 percentage point jumps.
  • Qualitative Emergence: Visualizing the pheromone matrix over 25 epochs shows a diffuse, noisy grid steadily crystallizing into a sharp, high-pheromone "golden path" (WebSearch $\rightarrow$ FetchHTML $\rightarrow$ WriteFile $\rightarrow$ ReadFile $\rightarrow$ RunCmd), while useless detours fade to zero.

Limitations and Future Work

  • Reliance on Reference Trajectories: Pheromone deposition scores are calculated using match ratios against reference trajectories, and the progressive curriculum relies on oracle actions during training. Extending this to broader, purely outcome-driven verification settings remains future work.
  • Rigid Argument Modeling: Argument invocations are chosen from pre-constructed frequent templates and are not parameterized or updated by the LLM policy optimization itself. The authors point toward richer argument-invocation modeling and handling dynamic environments with evolving APIs as key next steps.

Summary updated

Abstract

Recent advancements in Large Language Model (LLM) agents have demonstrated strong capabilities in executing complex tasks through tool use. However, long-horizon multi-step tool planning is challenging, because the exploration space suffers from a combinatorial explosion. In this scenario, even when a correct tool-use path is found, it is usually considered an immediate reward for current training, which would not provide any reusable information for subsequent training. In this paper, we argue that historically successful trajectories contain reusable tool-transition patterns, which can be leveraged throughout the whole training process. Inspired by ant colony optimization where historically successful paths can be reflected by the pheromone, we propose Pheromone-Guided Policy Optimization (PhGPO), which learns a trajectory-based transition pattern (i.e., pheromone) from historical trajectories and then uses the learned pheromone to guide policy optimization. This learned pheromone provides explicit and reusable guidance that steers policy optimization toward historically successful tool transitions, thereby improving long-horizon tool planning. Comprehensive experimental results demonstrate the effectiveness of our proposed PhGPO.
BibTeX
@inproceedings{li2026phgpo,
  author = {Yu Li and Guangfeng Cai and Shengtian Yang and Han Luo and Shuo Han and Xu He and Dong Li and Lei Feng},
  title = {{PhGPO: Pheromone-Guided Policy Optimization for Long-Horizon Tool Planning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=sAUmVeY7RI},
}
Figure