English

Scaling Long-Horizon LLM Agent via Context-Folding

Computation and Language 2025-10-15 v1 Machine Learning

Abstract

Large language model (LLM) agents are fundamentally constrained by context length on long-horizon tasks. 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 develop an end-to-end reinforcement learning framework FoldGRPO with specific process rewards to encourage effective task decomposition and context management. On complex long-horizon tasks (Deep Research and SWE), our folding agent matches or outperforms the ReAct baselines while using an active context 10×\times smaller and significantly outperforms models that rely on summarization-based context management.

Keywords

Cite

@article{arxiv.2510.11967,
  title  = {Scaling Long-Horizon LLM Agent via Context-Folding},
  author = {Weiwei Sun and Miao Lu and Zhan Ling and Kang Liu and Xuesong Yao and Yiming Yang and Jiecao Chen},
  journal= {arXiv preprint arXiv:2510.11967},
  year   = {2025}
}
R2 v1 2026-07-01T06:35:04.744Z