Lune

ICML2026Top-tier venue

Scaling Long-Horizon Agent via Context Folding

Weiwei Sun, Lu Miao, Zhan Ling, Kang Liu, Xuesong Yao, Yiming Yang, Jiecao Chen

Abstract

Large language model (LLM) agents are fundamentally constrained by context length on long-horizon tasks. Existing agent frameworks usually rely on manually defined context engineering pipelines, such as multi-agent or post-hoc summary. We introduce Context Folding, a framework that empowers agents to actively manage their working context. An agent can procedurally branch into a sub-trajectory to handle a subtask and then fold it upon completion, collapsing the intermediate steps while retaining a concise summary of the outcome. To make this behavior learnable, we propose FoldGRPO, an end-to-end reinforcement learning framework with specific process rewards to encourage effective task decomposition and context management. On long-horizon tasks, our agent matches the performance of baselines while using an active context up to 10x smaller, and significantly outperforms models constrained to the same context size. Code is available at https://github.com/sunnweiwei/FoldAgent.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

4 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Tree of Thoughts: Deliberate Problem Solving with Large Language Models cites Language Models as Zero-Shot Planners: Extracting Actionable Knowledge for Embodied Agents
  • LightWM: Training-Free Hierarchical Working Memory for Small Language Model Agents cites Tree of Thoughts: Deliberate Problem Solving with Large Language Models
  • LightWM: Training-Free Hierarchical Working Memory for Small Language Model Agents cites Graph of Thoughts: Solving Elaborate Problems with Large Language Models
  • ACON: Optimizing Context Compression for Long-horizon LLM Agents cites SWE-bench: Can Language Models Resolve Real-world Github Issues?
  • Graph of Thoughts: Solving Elaborate Problems with Large Language Models cites Tree of Thoughts: Deliberate Problem Solving with Large Language Models
  • Graph of Thoughts: Solving Elaborate Problems with Large Language Models cites Language Models as Zero-Shot Planners: Extracting Actionable Knowledge for Embodied Agents
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers4

  1. Resolving Evidence Sparsity: Agentic Context Engineering for Long-Document UnderstandingKeliang Liu, Zizhi Chen, Mingcheng Li, Jingqun Tang et al.CVPR 2026 · 19 citations
  2. Mem-T: Densifying Rewards for Long-Horizon Memory AgentsYanwei Yue, Guibin Zhang, Boci Peng, Xuanbo Fan et al.ICML 2026
  3. LightWM: Training-Free Hierarchical Working Memory for Small Language Model AgentsZiyi Wang, Haonan Jin, Zian Wang, Wendong Wang et al.ICML 2026
  4. ACON: Optimizing Context Compression for Long-horizon LLM AgentsMinki Kang, Wei-Ning Chen, Dongge Han, Huseyin Inan et al.ICML 2026

Builds on15

  1. Tree of Thoughts: Deliberate Problem Solving with Large Language ModelsShunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran et al.NeurIPS 2023 · 5,068 citations
  2. Transformers are RNNs: Fast Autoregressive Transformers with Linear AttentionAngelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François FleuretICML 2020 · 2,665 citations
  3. SWE-bench: Can Language Models Resolve Real-world Github Issues?Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao et al.ICLR 2024 · 2,082 citations
  4. Language Models as Zero-Shot Planners: Extracting Actionable Knowledge for Embodied AgentsWenlong Huang, Pieter Abbeel, Deepak Pathak, Igor MordatchICML 2022 · 1,539 citations
  5. Graph of Thoughts: Solving Elaborate Problems with Large Language ModelsMaciej Besta, Nils Blach, Ales Kubicek, Robert Gerstenberger et al.AAAI 2024 · 1,292 citations

Related papers

  1. U-Fold: Dynamic Intent-Aware Context Folding for User-Centric AgentsJin Su, Runnan Fang, Yeqiu Li, Xiaobin Wang et al.ACL Findings 2026
  2. AgentFold: Long-Horizon Web Agents with Proactive Context FoldingRui Ye, Zhongwang Zhang, Kuan Li, Huifeng Yin et al.ICLR 2026 · 45 citations
  3. Beyond the Context Window: Scaling Agentic RL via End-to-end Optimized Context CompressionMiao Lu, Weiwei Sun, Weihua Du, Zhan Ling et al.ACL 2026
  4. Context as a Tool: Context Management for Long-Horizon SWE-AgentsShukai Liu, Bo Jiang, Jian Yang, Yizhi Li et al.ACL Findings 2026
  5. PACE: Predictive Adaptive Context Extraction for Long-Horizon LLM AgentsLei Wei, Xiao Peng, TT, Guannan Zhang et al.ACL 2026
Dusk over the sea between two cliffs drawn in fine vertical lines