STAPO: Selective Trajectory-Aware Policy Optimization for LLM Agent Training

Qiuyi Qi, Tian Liang, Mutian Bao, Jinjian Zhang, Dongnan Liu, Wei Zhou, Linjian Mo, Ming Kong, Jie Liu, Feng Zhang, Qiang Zhu

TL;DR

Large Language Model (LLM) agents training on long-horizon tasks often suffer from "trajectory neglect," where they lose track of goals and history at intermediate steps. This paper introduces STAPO, a hierarchical reinforcement learning framework that uses a novel normalized entropy metric to pinpoint these neglectful steps and selectively optimize them. By combining a trajectory-aware reward with a trajectory-independent penalty, STAPO achieves state-of-the-art performance across complex agentic benchmarks while maintaining training stability.

What Problem Does This Paper Address?

When LLM agents tackle complex, multi-step tasks—like navigating an e-commerce site or controlling a robot—they rely on Reinforcement Learning (RL) to learn from environment feedback. However, because rewards are usually sparse and delayed (often given only at the very end of a task), agents frequently experience trajectory neglect. During long interaction sequences, the agent loses focus on the main goal or forgets its interaction history, leading to repetitive, cyclic, or completely irrelevant actions at intermediate steps.

To fix this, previous methods tried to monitor step-level uncertainty using Shannon entropy. The flaw? Shannon entropy conflates inherent state complexity (a situation where many different actions are perfectly reasonable) with low agent confidence (the agent being genuinely lost). As a result, standard entropy provides a noisy, unreliable signal for finding where an agent is actually failing.

Shannon Entropy vs Normalized Entropy

Methods

The authors propose STAPO (Selective Trajectory-Aware Policy Optimization), a hierarchical group-based RL framework that operates in two main phases:

  1. Outlier Localization via Normalized Entropy: To decouple state complexity from true agent confusion, the authors introduce normalized entropy. They group semantically similar states together across sampled trajectories (anchor state grouping). They then calculate the standard Shannon entropy for an action and compute its Z-score relative to that specific state group. Steps with anomalously high normalized entropy are flagged as outliers using the Interquartile Range (IQR) method.
  2. Selective Optimization: Instead of optimizing all steps indiscriminately, STAPO applies a targeted joint optimization mechanism only to the flagged outlier steps:
  3. Trajectory-Aware Reward ($R_{TA}$): Measures how much the agent's action distribution depends on the trajectory context. It calculates the KL divergence between the policy's output given the full prompt versus a "trajectory-blind" prompt (where the goal and history are masked out). Maximizing this forces the model to actively leverage its history.
  4. Trajectory-Independent Penalty ($P_{TI}$): To prevent "reward hacking" (where the model might distort its trajectory-blind distribution just to inflate the reward), this penalty ensures the model's behavior on the masked prompt stays close to the reference policy.

Well-behaved steps (inliers) are optimized normally using a standard group-based RL objective.

STAPO Framework

Datasets

The framework was evaluated on three diverse, long-horizon benchmarks:

  • ALFWorld: An embodied environment requiring multi-step household decision-making (e.g., locating, cleaning, and placing objects).
  • WebShop: A complex web-navigation environment where agents must search, navigate, and purchase items on a simulated e-commerce site based on user instructions.
  • Search-Augmented QA: Multi-turn tool-calling tasks split into single-hop datasets (NQ, TriviaQA, PopQA) and multi-hop datasets (HotpotQA, 2Wiki, MuSiQue, Bamboogle).

Key Insights and Ideas

  • Decoupling Complexity from Confidence: High entropy doesn't always mean an agent is lost; sometimes a state just naturally has many valid choices. Normalizing entropy within state groups reveals the true trajectory neglect signals, showing a strong correlation with low-quality actions.
  • Targeted Intervention Beats Bludgeoning: Optimizing every single step with trajectory-heavy rewards can destabilize training or cause mode collapse. Selectively intervening only on outlier steps preserves base policy stability while fixing critical failures.
  • Breaking the Cold-Start Deadlock: In tough environments like WebShop, standard RL baselines often fail to get any successful rewards early on, leading to flatlined training. STAPO's trajectory-aware reward provides continuous, non-zero internal guidance right from the start, steering the agent out of exploration deadlocks.
Empirical Analysis of Outliers

Key Results

  • State-of-the-Art Performance: STAPO consistently outperformed strong baselines (including PPO, GRPO, and GiGPO) across all benchmarks and model scales (Qwen2.5 and Llama3.1).
  • ALFWorld: Reached a near-perfect 96.9% success rate with Qwen2.5-7B-Instruct.
  • WebShop: Boosted the success rate of Qwen2.5-1.5B-Instruct to 69.0% (up from GiGPO's 65.0%).
  • Efficiency: STAPO achieves these gains with a marginal computational overhead of only ~5.7% extra training time per step, proving far more efficient and robust than brute-force scaling of sample group sizes.

Limitations and Future Work

  • Batch Support Dependency: Normalized entropy relies on having multiple samples of the same or similar states within a training batch. If a state is visited only once, the metric effectively reduces to standard Shannon entropy. This makes it less effective in environments with massive, sparse action spaces where state revisitation is rare.
  • Modality Constraints: The primary evaluations were conducted on text-based agents. While the authors include a small pilot study on vision-language models (Qwen2.5-VL), more extensive work is needed to fully characterize outlier behavior under complex visual interfaces.

Summary updated

BibTeX
@inproceedings{qi2026stapo,
  author = {Qiuyi Qi and Tian Liang and Mutian Bao and Jinjian Zhang and Dongnan Liu and Wei Zhou and Linjian Mo and Ming Kong and Jie Liu and Feng Zhang and Qiang Zhu},
  title = {{STAPO: Selective Trajectory-Aware Policy Optimization for LLM Agent Training}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.acl-long.1308},
}
Figure