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 about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext d6b024a4-0b57-461c-8637-3fa163f1701aCited by top-tier papers4
- Resolving Evidence Sparsity: Agentic Context Engineering for Long-Document UnderstandingKeliang Liu, Zizhi Chen, Mingcheng Li, Jingqun Tang et al.CVPR 2026 · 19 citations
- Mem-T: Densifying Rewards for Long-Horizon Memory AgentsYanwei Yue, Guibin Zhang, Boci Peng, Xuanbo Fan et al.ICML 2026
- LightWM: Training-Free Hierarchical Working Memory for Small Language Model AgentsZiyi Wang, Haonan Jin, Zian Wang, Wendong Wang et al.ICML 2026
- ACON: Optimizing Context Compression for Long-horizon LLM AgentsMinki Kang, Wei-Ning Chen, Dongge Han, Huseyin Inan et al.ICML 2026
Builds on15
- Tree of Thoughts: Deliberate Problem Solving with Large Language ModelsShunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran et al.NeurIPS 2023 · 5,068 citations
- Transformers are RNNs: Fast Autoregressive Transformers with Linear AttentionAngelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François FleuretICML 2020 · 2,665 citations
- 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
- Language Models as Zero-Shot Planners: Extracting Actionable Knowledge for Embodied AgentsWenlong Huang, Pieter Abbeel, Deepak Pathak, Igor MordatchICML 2022 · 1,539 citations
- 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
- AgentFold: Long-Horizon Web Agents with Proactive Context FoldingRui Ye, Zhongwang Zhang, Kuan Li, Huifeng Yin et al.ICLR 2026 · 45 citations
- 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
- PACE: Predictive Adaptive Context Extraction for Long-Horizon LLM AgentsLei Wei, Xiao Peng, TT, Guannan Zhang et al.ACL 2026
- Agentic Memory: Learning Unified Long-Term and Short-Term Memory Management for Large Language Model AgentsYi Yu, Liuyi Yao, Yuexiang Xie, Qingquan Tan et al.ACL 2026 · 40 citations
- Chain of Agents: Large Language Models Collaborating on Long-Context TasksYusen Zhang, Ruoxi Sun, Yanfei Chen, Tomas Pfister et al.NeurIPS 2024 · 297 citations
