Spinning Straw into Gold: Relabeling LLM Agent Trajectories in Hindsight for Successful Demonstrations

Zi-Chao Li, Gang Wu, Jack Z. Wang, Ruiyi Zhang, Wan-Rong Zhu +3 more
7/1/2026

No confident code implementation found for this paper. 2 possible matches can be shown below.

Abstract

Large language model agents operate in partially observable, long-horizon settings where obtaining supervision remains a major bottleneck. We address this by utilizing a source of supervision overlooked in existing post-training methods: unintended yet successful goals embedded within agent rollouts.

Show full abstract

Specifically, we introduce Hindsight Supervised Learning (HSL), where an auxiliary LLM reviews each completed trajectory and relabels it with all of the natural-language goals the agent actually achieved. HSL then pairs the trajectory with its relabeled goals and uses these pairs for additional fine-tuning. To mitigate suboptimality in the relabeled data, we propose two learning techniques for HSL, irrelevant-action masking and sample reweighting. Our experiments show that HSL is flexible and compatible with existing post-training pipelines. It improves both SFT and DPO, with larger gains on long-horizon tasks with more diverse goal spaces. Moreover, HSL is sample-efficient: on ALFWorld, it surpasses baselines trained on the full dataset while using only one quarter of the ground-truth demonstrations.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 2 weaker matches are hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{li2026spinning,
  title  = {Spinning Straw into Gold: Relabeling LLM Agent Trajectories in Hindsight for Successful Demonstrations},
  author = {Zi-Chao Li and Gang Wu and Jack Z. Wang and Ruiyi Zhang and Wan-Rong Zhu and Ryan A. Rossi and Vlad I. Morariu and Jihyung Kil},
  year   = {2026},
  eprint = {2607.04235},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2607.04235},
  journal = {International Conference on Learning Representations}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2607.04235.svg)](https://codeofpaper.com/paper/2607.04235)

Discussion