ArXiv: 2510.11967
🎯 Pitch
LLM agents can maintain performance on complex, long-horizon tasks using a 10× smaller active context—by learning to dynamically offload subtask work into temporary branches and fold away the messy intermediate steps, keeping only concise summaries. This learned context-folding approach, driven by specialized process rewards, beats both standard ReAct and forced summarization baselines, showing that effective context management is a trainable skill, not a capacity limit.
1. Executive Summary
This paper introduces Context-Folding, a mechanism that enables LLM agents to actively manage their working context on long-horizon tasks by branching into sub-trajectories for subtasks and then folding the intermediate steps upon completion, retaining only a concise outcome summary (e.g., offloading web search or codebase exploration into branches while preserving only key findings for high-level reasoning). The authors develop FoldGRPO, an end-to-end reinforcement learning framework that augments GRPO with dynamic folded contexts and token-level process rewards — the Unfolded Token Penalty (discouraging token-heavy operations in the main thread), the Out-of-Scope Penalty (enforcing branch focus), and the Failure Penalty (penalizing failed tool calls) — to teach a Seed-OSS-36B-Instruct model effective task decomposition and context management. On BrowseComp-Plus and SWE-Bench Verified, the resulting Folding Agent achieves pass@1 scores of 62.0% and 58.0% respectively while using an active context 10× smaller (32K tokens with up to 10 branches vs. 327K full context), matching or exceeding ReAct baselines and substantially outperforming summarization-based context management — establishing that learned, active context management can substitute for raw context length, but only when the agent is trained with process rewards that explicitly shape branching and folding behavior.
2. Context and Motivation
The Core Problem: Linear History Growth Is an Existential Bottleneck for Long-Horizon Agents
The fundamental problem this paper addresses is deceptively simple: LLM agents accumulate interaction history linearly in their context window, and this linear growth becomes catastrophic on long-horizon tasks. The standard ReAct-style agent (Yao et al., 2022) appends every reasoning step, every tool call, and every observation to a single, ever-expanding context — and generates each subsequent action conditioned on the entire accumulated history. For tasks that require hundreds or thousands of interactions (deep research requiring dozens of web searches, software engineering requiring extensive codebase exploration and iterative debugging), this accumulation produces contexts that exceed even the largest practical context windows while simultaneously degrading the model's ability to use relevant information within them.
The paper is motivated by what it characterizes as a fundamental constraint of agentic framework design (Section 1), not merely a current model limitation. This is a crucial distinction: the authors argue that the problem lies in the architecture of interaction, not in any specific model's context length limit. Even if context windows were infinite — and they are not — the cost structure and attention degradation would remain. The paper cites several mechanisms that make this linear accumulation unsustainable as horizons scale:
-
Performance degradation from long contexts. LLMs are known to struggle with utilizing relevant information in excessively long contexts, with a well-documented "lost in the middle" phenomenon (Liu et al., 2023) where information in the middle of a long context is less effectively attended to. The paper explicitly cites this line of work (Section 1), noting that as agent trajectories grow, the model's reasoning and instruction-following capability drops — even if the context technically fits within the model's maximum length. This is not about hitting a hard truncation point; it's about progressive degradation as the working context expands (Section 2.1).
-
Quadratic computational scaling of attention. The self-attention mechanism in transformers scales quadratically with sequence length, making long-context inference expensive. Additionally, the KV-cache grows linearly with context, consuming memory and adding overhead. For agents deployed at scale, these costs compound per-turn and can make long-horizon tasks economically unviable regardless of whether the model can technically handle the length.
-
METR's finding on task length growth. The paper cites METR's (March 2025) observation that "the length of tasks agents can complete is argued to be growing exponentially, with a doubling time of about 7 months" (Section 1). If task complexity is growing exponentially while context handling scales at best quadratically in cost, there is a widening gap between what agents need to do and how they currently manage state. This frames the problem with urgency: without fundamental changes to how agents manage context, scaling to longer horizons will hit diminishing returns or become cost-prohibitive.
These three problems — degradation, cost, and scaling mismatch — are not independent. They compound: as tasks get longer, agents need more context, which costs more and degrades performance, which forces more exploration and interaction, which generates more context. The paper's core insight is that breaking this cycle requires active context management rather than passive accumulation.
Why This Problem Matters: Real-World Impact and Theoretical Significance
The importance of this problem extends beyond academic interest into practical deployment economics and the fundamental limits of agentic AI.
Practical deployment economics. Long-horizon agents are already being deployed for high-value tasks: deep research (Google Deep Research, OpenAI Deep Research), agentic coding (Claude Code, OpenHands, Cursor), and autonomous data analysis. Each of these applications involves extensive interaction with tools and environments, generating contexts that routinely exceed 100K tokens. The paper's experiments on BrowseComp-Plus (deep research) and SWE-Bench Verified (coding) are not contrived benchmarks — they represent real, commercially relevant workloads. The cost of inference for these agents is dominated by the quadratic scaling of attention on long contexts, meaning that reducing active context length directly translates to lower latency, lower cost, and higher throughput for deployed systems.
For example, a ReAct agent with a 327K-token context running thousands of queries per day incurs massive inference costs. If active context management can compress this to a 32K-token working window (a 10× reduction, as the paper demonstrates), the per-query inference cost drops substantially — not just from the shorter context itself, but from the ability to reuse KV-cache prefixes across branches. These savings compound at scale and can determine whether long-horizon AI agents are economically viable for mass deployment or remain a premium-only offering.
Theoretical significance: the memory-for-intelligence tradeoff. There is a deep architectural question embedded in this work: what is the right memory architecture for an LLM agent? The ReAct approach of keeping everything in-context treats the transformer's attention mechanism as a kind of perfect RAM — every past interaction is equally and directly accessible. But this is known to be false: transformers are lossy memories, with attention quality degrading as sequence length grows. The summarization approach treats memory as an external store that must be explicitly compacted, but compacts blindly at arbitrary boundaries. Context folding proposes a third model: structured working memory with explicit sub-goal boundaries, where memory is organized hierarchically and compressed at semantically meaningful transition points determined by sub-task boundaries. This connects to long-standing ideas in cognitive science and AI (sub-goaling, hierarchical task decomposition, the use of chunking to expand effective working memory) but applies them to the specific mechanism of an LLM's context window. The paper's reframing of context management as a learned cognitive skill rather than an engineering workaround (Section 5) elevates the problem from implementation details to a first-class research question about agent architecture.
Enablement of self-improvement loops. The paper's discussion of future directions (Section 6) notes that efficient context management is a prerequisite for iterative self-improvement, where agents generate their own training data over long trajectories. If each training trajectory is prohibitively expensive due to context length, the cost of generating high-quality fine-tuning data scales linearly with the number of iterations. Context folding reduces this cost, making self-improvement pipelines more feasible.
Where Existing Approaches Fall Short
The paper organizes prior context-management approaches into two categories and identifies specific, actionable limitations in each (Section 1, Section 5).
Summarization-Based Methods: Post-Hoc, Disruptive, and Blind to Structure
Summarization-based approaches (OpenHands context condensation, MemAgent, ReSum, Mem1, WebResearcher) trigger a compression stage when the working context fills up. The agent (or a separate summarization model) produces a summary of recent history, the full history is evicted, and the summary is inserted into the now-truncated context. This is essentially a garbage collection approach to agent memory.
The paper identifies several specific failure modes:
-
Abrupt disruption of reasoning flow (Section 1). When summarization is triggered — typically at a fixed token threshold — it interrupts the agent's working context arbitrarily. The agent may be in the middle of a multi-step reasoning chain, and the summarization step breaks that continuity. The summary replaces detailed intermediate steps with a compressed representation that may lose crucial nuances that the agent needed for its next reasoning step. The paper characterizes this as a "post-hoc" operation that "can abruptly disrupt the agent's working context and reasoning flow, which may lead to sub-optimal results" (Section 1).
-
Blind to sub-task boundaries. Summarization methods lack understanding of task structure. They may summarize across sub-task boundaries — merging the end of one sub-task and the beginning of another into a single compressed block — or split a sub-task in progress across two summary windows. Because they operate at fixed token limits rather than at semantically meaningful transition points, they risk either discarding important intermediate results or preserving irrelevant detail. Context folding, by contrast, compresses at sub-task boundaries explicitly signaled by the
returnaction, ensuring that the compression boundary aligns with a natural completion point. -
No learning mechanism for what to keep. Summarization is typically implemented as a prompt to the LLM ("summarize the conversation so far"), which relies on the model's generic summarization capability rather than task-specific training on what information is critical for subsequent decisions. The paper's approach trains the agent's folding behavior end-to-end through reinforcement learning, meaning the agent learns what to preserve in summaries based on actual downstream task performance.
-
Empirical underperformance (Table 1). The Summary Agent baseline in the paper's experiments uses the same base model (Seed-OSS-36B), the same 32K working context, the same number of summary windows (10), and the same RL training. On BrowseComp-Plus, it achieves 52.7% pass@1 with GRPO training, while the Folding Agent with FoldGRPO achieves 62.0% — a 9.3 percentage point gap. On SWE-Bench Verified, it's 55.0% vs. 58.0%. This controlled comparison — same model, same data, same budget, same RL — isolates the mechanism itself as the differentiating factor.
Multi-Agent Systems: Handcrafted, Brittle, and Resistant to End-to-End Optimization
Multi-agent approaches (Chain of Agents, LongAgent, Anthropic's multi-agent research system, WideSearch) decompose a task across multiple specialized agents, each with its own context window. The main agent delegates sub-tasks to worker agents, receives results, and synthesizes a final answer.
The paper acknowledges that context folding can be "interpreted as a specific formulation of a general multi-agent system" (Section 2.4) but identifies critical differences that address multi-agent shortcomings:
-
Predefined vs. dynamically created agents. Multi-agent systems typically define agent roles and responsibilities in advance — a planner agent, a retrieval agent, a code agent, etc. This works for domains where the task structure is known, but fails when tasks require ad hoc decomposition that doesn't match predefined agent categories. Context folding creates sub-agents "on the fly" based on the specific decomposition the main agent decides for this task, making it adaptable to arbitrary problem structures.
-
Handcrafted workflows resist optimization. Multi-agent systems "typically depend on handcrafted, problem-specific workflows that are difficult to generalize" (Section 1). These workflows are designed by humans based on their understanding of the domain, and they cannot be automatically improved through experience. If a human-designed workflow is suboptimal for certain problem instances, the system has no mechanism to adapt. Context folding, by training the branching behavior end-to-end with RL, learns a task decomposition strategy that optimizes for final task success — not for adherence to a human-designed workflow.
-
KV-cache inefficiency. In typical multi-agent setups, different agents may have different system prompts or conversation histories, requiring separate KV-cache computation for each agent. Context folding addresses this by having all branches share the same context prefix (the main thread up to the
branchcall), making it "KV-cache friendly" (Section 2.4). When a branch is created, the KV-cache up to that point is reused; when it returns, the cache is rolled back to the prefix, avoiding redundant computation. -
Parallel vs. interleaved execution. Multi-agent systems often run agents in parallel, which is beneficial for throughput but can miss dependencies between sub-tasks. Context folding interleaves main-thread planning and branch execution — the main agent plans, creates a branch, waits for its result, incorporates that result into its planning, and then creates the next branch. This sequential, dependency-aware execution can be more appropriate for tasks where sub-problems build on each other (which the paper's parallel branching experiment suggests may be the case for their benchmarks — Section 4.5.3).
The Limitations of Vanilla RL for Teaching Context Management
The paper's motivation goes beyond identifying problems with existing context-management approaches. It also identifies a learning problem: standard reinforcement learning with sparse outcome rewards is insufficient for teaching agents effective context management. The paper reports two critical failure modes observed empirically when training context-folding agents with vanilla GRPO (Section 2.3.2):
-
Strategic planning failure. The agent fails to offload token-intensive operations into branches. Instead, it performs web searches, reads documents, and conducts exploration directly in the main context. This quickly exhausts the 32K-token working context budget, leaving no room for the high-level planning that the main thread is supposed to handle. The agent essentially uses the folding mechanism as a passive feature rather than learning to actively decompose tasks across branches. The "Finish" rate for the GRPO-trained folding agent on BrowseComp-Plus drops to 73.8% (Table 2) — meaning over a quarter of trajectories fail to complete within the context limit because the main thread is too bloated.
-
Branch management failure. The agent fails to properly scope sub-tasks within branches and fails to return from branches when sub-tasks are complete. Instead, it continues subsequent work within the same branch, effectively turning branches into just a continuation of the main thread and defeating the purpose of context isolation. The "Scope" accuracy for the GRPO-trained agent on SWE-Bench Verified drops to 41.9% (Table 2), meaning more than half of branch work goes outside the specified sub-task. This is not just inefficient — it means the agent cannot reliably isolate sub-problems, which undermines the entire context-folding architecture.
These failures are not obvious a priori. One might reasonably expect that an agent trained with outcome rewards would discover effective decomposition as an emergent strategy — after all, better task decomposition should produce better outcomes. The paper's empirical finding that this does not happen without explicit process rewards is a significant motivation for FoldGRPO. The sparse reward signal from final task success is too weak and too delayed to shape the branching and folding behavior across hundreds of tool calls. The process rewards — the Unfolded Token Penalty, the Out-of-Scope Penalty, and the Failure Penalty — provide dense, token-level guidance that bridges the gap between the final outcome and the intermediate decisions that produce it.
How This Paper Positions Itself
The paper positions context folding as a third paradigm for context management that synthesizes and improves upon both summarization and multi-agent approaches (Sections 1, 2.4, 5):
-
Vs. summarization: Context folding is a learnable and boundary-aligned compression mechanism. Unlike blind summarization at arbitrary token limits, folding compresses at sub-task boundaries explicitly signaled by the agent. Unlike generic summarization prompts, folding behavior is trained end-to-end with RL so the agent learns what information to preserve based on downstream task success. The paper frames this as an "active" rather than "passive" approach to memory management — the agent decides when and what to compress, rather than having compression happen to it.
-
Vs. multi-agent systems: Context folding provides a specific, lightweight instantiation of the multi-agent idea that is trainable rather than handcrafted, shares KV-cache prefixes for efficiency, and interleaves rather than parallelizes agent execution. The paper is careful not to claim superiority over all multi-agent approaches, but rather to position context folding as filling a specific gap: the ability to learn task decomposition end-to-end from outcome signals.
The paper's most significant positioning move is its reframing of context management as a learned cognitive skill rather than an architectural feature (Section 5). The related work section explicitly notes that prior approaches "frame context management as an architectural or retrieval problem, leaving a gap for an integrated approach where it becomes a learned cognitive skill rather than an external feature." This reframing is important because it changes the research question from "what mechanism should we build to manage context?" to "how do we teach an agent to manage its own context?" The answer — FoldGRPO with dense process rewards — is specific to this paper, but the reframing opens a broader research direction: using reinforcement learning to teach agents meta-cognitive skills around memory and attention management that have traditionally been hand-engineered.
The paper also positions itself relative to the broader scaling conversation. The results showing that a 32K working-context agent can match a 327K-context agent (Table 1) — and that the benefits grow with task complexity (Figure 5, right) — make the case that context quality matters more than context quantity. For tasks within the agent's capability range, efficient context management can substitute for raw context length. This echoes the test-time compute scaling literature but applied to the memory dimension: just as smart test-time compute allocation can substitute for model size, smart context management can substitute for context window size.
3. Technical Approach
This is primarily a systems-and-training paper whose core idea is that LLM agents can learn to actively manage their own context through a branching-and-folding mechanism, but only if trained with process rewards that explicitly shape when and how to decompose tasks, isolate sub-problems into branches, and return concise summaries rather than accumulating unbounded history.
3.1 Reader Orientation
The paper builds a trainable agent architecture where a single LLM, using two special actions (branch and return), can spawn isolated sub-trajectories for sub-tasks, complete them, fold away the intermediate steps, and resume the main thread with only a concise outcome summary — all while keeping its active working context compact (32K tokens). The system solves the problem of linear context growth on long-horizon tasks by replacing passive history accumulation with active, learned context management: the agent decides when to offload work into a branch, what sub-task to assign, and what information to preserve upon returning, with all three decisions optimized end-to-end through reinforcement learning to maximize final task success.
3.2 Big-Picture Architecture (Diagram in Words)
The system has five major components, organized around a plan–execution cycle:
-
Base LLM (Seed-OSS-36B-Instruct) — the pretrained language model that serves as both the main planning agent and the branch execution agent. All actions (reasoning, tool calls, branch creation, return) are generated by this single model under different context conditions.
-
Context Manager (
F) — a KV-cache-aware mechanism that implements the folding operation: when the agent callsreturn, the intermediate steps within that branch are removed from the active context, the KV-cache is rolled back to the correspondingbranchcall position, and only a summary message from the return call is appended to the main thread. This is the runtime mechanism that enforces the 32K-token working context limit while allowing up to 10 branches (theoretical maximum 327,680 total tokens across all branches). -
Plan–Execution Scaffold — a state machine that enforces two modes: Planning State in the main thread (where the agent does high-level reasoning, decomposes tasks, and decides when to branch — but is discouraged from token-intensive tool use) and Execution State within a branch (where the agent performs the assigned sub-task using full tool access, but cannot create nested branches). This scaffold is not learned; it is a hard constraint built into the environment.
-
FoldGRPO Training Framework — an extension of GRPO (Group Relative Policy Optimization) that modifies how policy gradients are computed: during training, the context manager folds rollout history so that the policy is always conditioned on the folded context (matching inference conditions), and token-level process rewards are added to the advantage estimates to guide branching behavior.
-
Process Reward Design — three dense, token-level reward signals that address specific failure modes: the Unfolded Token Penalty (–1 to main-thread tokens when context exceeds 50% limit), the Out-of-Scope Penalty (–0.2 to branch tokens for off-task work), and the Failure Penalty (–1 to tokens in failed tool call turns). These are computed per-token and added to the group-relative advantage estimate during training.
Information flows as follows: a question q enters → the agent starts in Planning State in the main thread → it reasons, may call domain tools (search, open_page, execute_bash) sparingly, and decides to branch(description, prompt) → the context manager creates an isolated branch context sharing the KV-cache prefix up to the branch point → the agent enters Execution State within the branch, uses tools freely, and eventually calls return(message) → the context manager folds the branch's intermediate steps, rolls back the KV-cache, and appends the return message to the main thread → the agent resumes Planning State, incorporates the branch result, and repeats until it calls finish.
3.3 Roadmap for the Deep Dive
- First, the vanilla ReAct formulation (Section 2.1) — what exactly is the problem with linear history accumulation, formalized as a probability model, so we understand what context folding changes.
- Second, the context-folding mechanism itself (Section 2.2) — the
branchandreturntools, the context managerF, the plan–execution instantiation, and the inference-time KV-cache management that makes this efficient. - Third, the FoldGRPO training framework (Section 2.3.1) — how GRPO is modified to fold context during training, the learning objective, the advantage estimator, and why standard GRPO fails for this setting.
- Fourth, the process reward design (Section 2.3.2) — the three token-level penalties, when they fire, their magnitudes, and why each addresses a specific empirically observed failure mode.
- Fifth, the implementation details (Section 3.2, Appendix A) — training configurations, the asynchronous rollout mechanism for long-horizon tasks, the multi-trajectory construction for efficient training, and the relationship to existing infrastructure.
3.4 Detailed, Sentence-Based Technical Breakdown
Vanilla ReAct Formulation: Why Linear Accumulation Is the Problem
The paper first formalizes the standard ReAct agent to establish the baseline that context folding replaces (Section 2.1). Given a question q, a ReAct agent generates a multi-turn interaction trajectory:
τ := (a_1, o_1, a_2, o_2, …, a_T, o_T)
where a_i is the LLM's output at step i (including reasoning text and tool calls) and o_i is the corresponding tool-call result (the observation returned by the environment). This trajectory is generated under the following probability model:
where π_θ is the policy (the LLM parameterized by θ), T is the total number of turns, and (a_1, o_1, …, a_{i-1}, o_{i-1}) is the complete interaction history up to step i.
What it computes: each action a_i is generated by conditioning the LLM on the original question q concatenated with the entire history of all previous actions and observations. The joint probability of the full trajectory is the product of these per-step conditional probabilities. This is the standard autoregressive generation model applied to multi-turn agent interactions.
Why this form is the problem: the conditioning context for step i grows linearly with i. After 100 turns of web search — each involving a reasoning paragraph, a search call, a list of 10 search results with snippets, a selected URL, an open_page call, and up to 4096 tokens of page content — the context can easily reach hundreds of thousands of tokens. At this point, three things break simultaneously: (1) the model's ability to attend to relevant early information degrades, (2) the per-token generation cost scales quadratically with the full context length (due to attention), and (3) the KV-cache memory footprint grows linearly, potentially exceeding hardware limits. The paper notes (Section 2.1) that this is not just a theoretical limit — "when the context is expanding, the reasoning and instruction following capability of the model may drop, posing further challenges for the agent to complete the long-horizon task."
The key insight of the paper is that this formulation treats all history as equally relevant to every future decision. Context folding changes what history the model conditions on — not everything, but a structured, compressed representation that preserves decision-relevant information while discarding execution details.
The Context-Folding Mechanism: Branch, Return, and the Context Manager
Context folding replaces the unbounded conditioning context with a managed, folded context through two special tools and a context manager function (Section 2.2).
The branch tool. The agent calls branch(description, prompt) from the main thread to create an isolated sub-trajectory. The description parameter is "a concise 3-5 word identifier for the sub-task" (Appendix C.3) — a short label like "Find publication with specific authors" or "Confirm Das's Ph.D. and co-author details" (from the case study in Figure 7). The prompt parameter is a "clear, compact task prompt" that "state[s] objectives and critical info to preserve in the response." This prompt becomes the initial context for the branch, providing the sub-agent (which is the same LLM instance) with the specific instructions and relevant background extracted from the main thread. The tool returns a template message indicating that the branch was created — the actual work happens in the isolated context.
The return tool. When the sub-task is complete (or when the agent cannot proceed further), the agent calls return(message) from within the branch. The message parameter is "a comprehensive message describing sub task outcome" (Appendix C.3) — this is the only information that survives the fold and re-enters the main thread. Upon calling return, two things happen simultaneously: (1) the agent's context switches back to the main thread at the point immediately after the corresponding branch call, and (2) a templated message containing the message field is appended to the main thread, serving as the observation o for that turn. All intermediate steps within the branch — all reasoning, tool calls, and observations between branch and return — are discarded from the active context.
The context manager F. Formally, the context-folding agent is modeled as:
where τ_{<i} = (a_1, o_1, …, a_{i-1}, o_{i-1}) is the complete history of all action-observation pairs before step i, and F is the context manager that folds the interaction history between branch and return tool calls.
What it computes: this is identical to the ReAct formulation except that the conditioning history is F(τ_{<i}) rather than the raw τ_{<i}. The function F takes the complete history and removes all segments that occurred inside branches, replacing each branch segment with only the return message. The policy sees a compact context where branch execution is summarized by its outcome.
Why this form: it decouples the amount of work done from the amount of context consumed. The agent can perform extensive tool use (dozens of searches, page reads, code executions) within branches, but only the final summary survives in the main context. This breaks the linear relationship between interaction count and context length that plagues ReAct. The tradeoff is that the agent must learn to produce summaries that contain sufficient information for downstream decisions — a skill the RL training explicitly optimizes.
Concrete example of folding (from Section 2.2). Consider a trajectory with two branches:
F(a_1, o_1, a_2, o_2, a_3, o_3, a_4 [branch 1], o_4, a_5, o_5, a_6, o_6, a_7, o_7, a_8 [branch 2], o_8, a_9, o_9, a_10, o_10) → (a_1, o_1, a_2, o_4, a_5, o_8, a_9, o_9, a_10, o_10)
Here, a_2 is the branch call for branch 1, a_3 and o_3, a_4 are the work done inside branch 1, o_4 is the return message from branch 1. Similarly, a_5 starts branch 2, a_6, o_6, a_7, o_7, a_8 is the work inside branch 2, and o_8 is the return message. After folding, the segments between a_2 and o_4 (branch 1's internals) and between a_5 and o_8 (branch 2's internals) are removed. The folded history is: main thread step 1, branch 1 creation and its outcome, branch 2 creation and its outcome, main thread steps 9 and 10.
Inference-time KV-cache efficiency (Section 2.2). The paper emphasizes that context folding is not just a conceptual model — it has a specific, efficient implementation using KV-cache manipulation. When the agent calls branch, the current KV-cache state is preserved (this is the prefix shared by the main thread and all branches). The branch then extends from this prefix, accumulating its own KV-cache entries for its internal steps. When return is called, the system rolls back the KV-cache to the preserved prefix state — the cache entries for the branch's internal steps are discarded. The return message is then appended as a new turn, extending the prefix KV-cache with a single new entry. This means that (1) branch execution does not permanently inflate the KV-cache, (2) the main thread maintains a small, constant-size KV-cache representing only the folded history, and (3) the shared prefix avoids recomputing attention for the common context.
The plan–execution instantiation (Section 2.2). To provide structure for long-horizon tasks without over-constraining the agent, the paper adopts a plan–execution framework as the concrete instantiation of context folding:
-
Planning State (main thread): The agent performs high-level reasoning, decomposes the task, and decides when to initiate a branch for a sub-task. Token-intensive tool use (web search with full page reading, codebase exploration, running test suites) is discouraged in this state — the design intent is to keep the main context focused on high-level strategies, not execution details. The agent can still use tools in the main thread, but the process rewards (detailed below) penalize doing so excessively.
-
Execution State (within a branch): The agent operates within an active branch to complete its assigned sub-task. It has full access to all domain tools. Creating new branches is disabled in this state — "To maintain a clear structure and prevent nested complexity" (Section 2.2). This is a hard constraint enforced by the scaffold, not a learned behavior. The agent must complete the sub-task and call
returnbefore any further branching can occur.
This state machine is not learned — it is a structural constraint that simplifies the learning problem by preventing the agent from creating deeply nested, hard-to-credit-assign trajectories. The RL training then teaches the agent when to transition from Planning to Execution (by calling branch) and what to include in the return message.
FoldGRPO: End-to-End RL with Folded Contexts
The paper's key algorithmic contribution is FoldGRPO, which modifies the standard GRPO algorithm in two ways to support context-folding agents: (1) it applies the context manager F during training rollouts so the policy is always conditioned on folded history (matching inference conditions), and (2) it augments the advantage estimate with token-level process rewards that directly guide branching behavior (Section 2.3).
Training setup. For each question q sampled from the training dataset D, G trajectories (τ_1, τ_2, …, τ_G) are sampled from the old policy π_old according to the context folding model (1) — meaning the rollouts use branch and return tools and the context is folded at each step. Each trajectory τ_i is a sequence of tokens [τ_{i,1}, …, τ_{i,|τ_i|}], and each trajectory receives a binary final reward R_i ∈ {0, 1} based on whether the task was completed successfully (following the RL from verifiable rewards, or RLVR, recipe where correctness can be automatically checked — via the BrowseComp-Plus LLM judge or SWE-Bench unit tests).
The FoldGRPO objective:
where r_{i,t}(θ) is the importance sampling ratio, Â_{i,t} is the group-relative advantage estimate, ε_low and ε_high are clipping parameters (set to 0.2 and 0.28 respectively, per Section 3.2), and the expectation is over questions and sampled trajectory groups.
What it computes: the standard GRPO clipped surrogate objective, summed over all tokens in all trajectories in the group. For each token, it computes the product of the importance sampling ratio and the advantage, clips the ratio to prevent overly large updates, takes the minimum of clipped and unclipped (pessimistic clipping), and averages across tokens. The inner sum over i and t normalizes by the total number of tokens across the group, making the objective invariant to trajectory length.
Why this form: GRPO's group-relative advantage (comparing trajectory rewards within a group rather than using a learned value function) eliminates the need for a separate critic network, simplifying training. The clipping mechanism (from PPO) prevents the policy from changing too drastically in a single update, which is especially important for long-horizon trajectories where variance is high.
The importance sampling ratio:
where π_θ(τ_{i,t} | q, F(τ_{i,<t})) is the probability the current policy assigns to token τ_{i,t} given the folded history up to that token, π_{θ_old} is the probability under the old policy (used for sampling), and 1^{LLM}_{τ_{i,t}} is an indicator that is 1 only for tokens generated by the LLM (masking out tokens from tool observations, which the policy does not control).
What it computes: for each token, the ratio of the current policy's probability to the old policy's probability. A ratio > 1 means the current policy has become more likely to generate this token; a ratio < 1 means it has become less likely. Multiplying by 1^{LLM} ensures that only tokens the model actually produces contribute to the gradient — environment observations are treated as fixed and not optimized.
Why the LLM mask matters: without this mask, the gradient would attempt to increase the probability of favorable tool observations and decrease the probability of unfavorable ones — but tool observations are generated by the environment, not the policy. This would add noise to the gradient and potentially cause the policy to learn spurious correlations. The mask ensures credit is only assigned to the model's own decisions.
The group-relative advantage estimator:
where R_i is the binary final reward for trajectory i, Q_{i,t} is the token-level process reward for token t in trajectory i (detailed in the next section), and mean({R_i}) and std({R_i}) are the mean and standard deviation of final rewards across the group of G trajectories.
What it computes: the advantage of each token in trajectory i relative to the group average. The first term, clip(R_i + Q_{i,t}, 0, 1), combines the sparse outcome reward with the dense process reward and clips to [0, 1] to keep the signal bounded. The second term subtracts the group-normalized baseline: trajectories that perform better than the group average get positive advantage; those that perform worse get negative advantage. This is the "group relative" aspect — the advantage is computed within each group of G = 8 trajectories (per Section 3.2), not against a global baseline.
Why group-relative: it automatically adapts to task difficulty. For a very hard task where all trajectories fail (all R_i = 0), the advantage for all trajectories is near zero — the agent is not penalized for failing at an impossible task. For an easy task where all trajectories succeed, similarly, advantage is near zero — the agent is not rewarded for succeeding at a trivial task. The process reward Q_{i,t} then provides the only signal in these cases, guiding how the agent succeeds or fails rather than just whether it succeeds or fails.
The two key modifications highlighted in the paper (shown in red in the original text) are:
(i) Context folding in the policy conditioning. Unlike vanilla multi-turn RL algorithms that condition on the full interaction history τ_{i,<t} when computing policy probabilities, FoldGRPO applies F(τ_{i,<t}) — the folded history. This is critical because it means the policy is trained under the same context conditions it will see at inference time. If training conditioned on the full, unfolded history, the policy would learn to rely on information that will be unavailable at inference (the detailed intermediate steps within branches), creating a train-test mismatch that would degrade performance.
(ii) Process reward signal Q_{i,t} in the advantage. The token-level process reward is added to the outcome reward R_i before clipping. This provides a dense training signal at every token position, rather than only at the end of the trajectory. The magnitude and timing of Q_{i,t} are designed to target specific failure modes, as detailed next.
Implementation details (Section 3.2, Appendix A). The paper uses the VeRL framework for RL training with the following hyperparameters: rollout batch size 32, group size G = 8, PPO batch size 128, learning rate 1 × 10^{-6}, no KL divergence penalty term, clip high ε_high = 0.28, clip low ε_low = 0.2. Training runs for 50 steps (approximately 2 epochs). The maximum context length for the LLM is set to 32,768 tokens, with up to 10 branches allowed (theoretical maximum total tokens: 32,768 × 10 = 327,680). During inference, greedy decoding is used (temperature = 0).
Process Reward Design: Three Token-Level Penalties
The paper's design of process rewards is driven by two empirically observed failure modes of standard GRPO training on context-folding agents (Section 2.3.2): (i) the agent fails to offload token-intensive operations into branches, performing them directly in the main thread and exhausting the 32K-token budget, and (ii) the agent fails to properly scope sub-tasks within branches, continuing work beyond the assigned sub-task and failing to return. The three process rewards directly counter these failure modes.
Unfolded Token Penalty. When the total context length of the main thread exceeds 50% of the working context limit (i.e., when the main thread grows beyond 0.5 × 32,768 = 16,384 tokens), the penalty is applied: Q_{i,t} = –1 for all tokens in the main thread, except those tokens in the turns that create a branch (the branch function call itself and its arguments).
What it computes: a –1 penalty per token added to the main thread once it becomes "too long," with an explicit exemption for the act of creating a branch. This penalizes the agent for performing token-heavy actions (extensive web searches, reading long documents, verbose reasoning) directly in the main thread after the context has already grown substantial. The exemption for branch-creation tokens ensures the agent is not penalized for the solution — creating a branch — only for not using it.
Why 50% threshold: the threshold is set at 50% rather than 100% to give the agent a buffer. If the penalty only fired at 100% (context full), the agent would have no room to create a branch and receive its return message within the remaining budget. The 50% threshold ensures that when the penalty activates, the agent still has 16K+ tokens available to continue planning and incorporate branch results. This creates a gradient: as the main context grows, the pressure to offload work into branches increases, but the agent always has space to do so.
Why –1 magnitude: the penalty magnitude matches the magnitude of the outcome reward (which is 0 or 1), making the process reward a significant fraction of the total signal. A smaller penalty (e.g., –0.1) might be drowned out by the outcome reward; a larger penalty (e.g., –5) might dominate the signal entirely and cause the agent to avoid the main thread altogether. The –1 value means that an action in the main thread past the 50% threshold receives roughly the same penalty as failing the entire task — a strong disincentive.
Why exempt branch-creation tokens: without this exemption, the penalty would discourage the agent from creating branches — exactly the opposite of the intended behavior. If every token in the main thread past 50% is penalized, including the branch call, the agent learns to stop taking any actions in the main thread rather than to use branches. The exemption creates a specific "escape hatch": creating a branch is the only unpenalized action in a bloated main thread, which directly teaches the decomposition behavior.
Out-of-Scope Penalty. For each branch, an external judge model (GPT-5-nano) evaluates — based on the branch prompt and the return message — whether the agent conducted actions outside the specified sub-task. If the branch is judged to contain out-of-scope work, Q_{i,t} = –0.2 is applied to all tokens in that branch.
What it computes: a mild penalty (–0.2) on all branch tokens when the work done in the branch doesn't match the stated objective. This penalizes branch scope creep — the tendency for the agent to treat a branch as a general continuation of work rather than as a focused sub-task solver.
Why GPT-5-nano as judge: the paper uses an external LLM rather than a rule-based check because "in-scope vs. out-of-scope" is a semantic judgment. The branch prompt might say "Find publication with specific authors and topics," and the agent might search for related but non-matching publications. Detecting this requires understanding both the prompt's intent and whether the search actions align with that intent — a natural language understanding task well-suited to an LLM judge. GPT-5-nano is chosen presumably for its speed and low cost relative to larger models.
Why –0.2 magnitude: this penalty is deliberately smaller than the Unfolded Token Penalty (–1) and the Failure Penalty (–1). The reasoning is that out-of-scope work is a soft violation — it's inefficient and goes against the intended structure, but it's not as catastrophic as failing to complete the task or exhausting the main context. A smaller penalty nudges the agent toward better scoping without making it excessively risk-averse about using branches at all. If the penalty were –1, the agent might learn to avoid creating branches for fear of scope violations, which would defeat the purpose.
Failure Penalty. For any tool call that fails (e.g., a search that returns no results, a bash command with a non-zero exit code, a file edit that fails), Q_{i,t} = –1 is applied to all tokens in that turn.
What it computes: a –1 penalty on all tokens in a turn where a tool call fails. This directly penalizes the model for taking actions that don't produce useful results, encouraging it to learn which tool calls are likely to succeed and to recover gracefully from failures rather than continuing blindly.
Why this is necessary: in RLVR with only outcome rewards, the agent receives no signal about individual action quality — only whether the final answer was correct. An agent that makes 50 failed tool calls before accidentally finding the right answer receives the same +1 reward as an agent that makes 5 efficient, successful calls. The Failure Penalty provides per-turn feedback: failed calls are penalized regardless of final outcome, creating pressure toward efficient, successful tool use.
Default case. In all other cases (tokens that don't trigger any of the three penalties), Q_{i,t} = 0. The process reward adds no signal, and the advantage is determined solely by the outcome reward relative to the group.
Evidence of effectiveness (Table 2). The paper's ablation comparing GRPO and FoldGRPO provides quantitative evidence for these process rewards. With GRPO training (no process rewards), the folding agent on BrowseComp-Plus shows: Finish rate drops to 73.8% (from 80.6% untrained), main trajectory length increases to 22,285 tokens (from 12,195 untrained), and Scope accuracy drops to 76.2% (from 77.4% untrained). This means GRPO training actively made the agent worse at context management — it learned to do more work in the main thread (longer main trajectory), completed fewer trajectories within budget (lower Finish rate), and was less focused in branches (lower Scope).
With FoldGRPO training (process rewards enabled): Finish rate jumps to 93.5%, main trajectory length drops to 7,752 tokens, Scope accuracy rises to 89.5%, and number of branches increases to 4.98 (from 3.51 untrained). The agent learned to compress its main thread to roughly 8K tokens while processing over 100K total tokens across branches — achieving over 90% context compression. The SWE-Bench results show the same pattern: GRPO degrades context management (Finish drops from 78.1% to 61.2%, Scope from 47.3% to 41.9%) while FoldGRPO dramatically improves it (Finish to 96.2%, Scope to 75.4%).
Training Infrastructure: Multi-Trajectory Construction and Asynchronous Rollout
The paper describes two implementation innovations that make training context-folding agents practical with existing infrastructure (Appendix A).
Multi-trajectory construction (Appendix A.1). Training with context folding is not directly compatible with standard RL training infrastructure (e.g., VeRL) because these frameworks expect a single, linear sequence of tokens per trajectory. The branching structure of context folding creates a tree of contexts — the main thread and multiple branches, each with its own causal conditioning. The paper's solution is pragmatic: "instead of concatenating all sub-trajectories into one sequence, we keep them as separate causally conditioned sequences." Each branch is treated as its own training example that shares a prefix with the main thread. This preserves the correct causal structure (each branch only conditions on its prefix, not on other branches) while fitting into standard infrastructure.
Asynchronous rollout for long-horizon agents (Appendix A.2). The rollout time of long-horizon agents is highly imbalanced — some trajectories complete quickly (easy questions, early failure) while others take much longer (hard questions, extensive exploration). In synchronous training, faster jobs wait for the slowest job to finish, creating a "bubble" where GPU utilization drops. The paper mitigates this with a partially asynchronous scheme:
- A main rollout process runs until it completes 95% of the prompts in the current batch.
- The remaining 5% (the stragglers) are handled by a standalone rollout process that runs in parallel with the next training step.
- The training data for each step includes both the 95% of the current batch (on-policy) and the prompts from the previous step that were completed by the standalone process (off-policy, with a maximum of 5 off-policy steps).
Why 95% threshold: this is "adjusted based on the GPU configuration" and represents a tradeoff. A higher threshold (e.g., 99%) would mean less off-policy data but longer idle time waiting for the very slowest trajectory. A lower threshold would mean more off-policy data but better GPU utilization. The paper reports that with a maximum of 5 off-policy steps, they "observe no performance degradation compared to training on fully on-policy data" — an important empirical finding that validates the asynchronous approach.
Training speed comparison (Figure 8). The paper reports that the 327K ReAct model requires 1.52× longer for rollout and 1.43× longer per training step compared to the folding agent (32K × 10). This is despite the folding agent having the same total token budget — the difference comes from the folding agent's shorter active context, which reduces the per-token generation cost and the KV-cache memory pressure during training.
Design Choices Summary and Justification
Why plan–execution rather than unrestricted branching. Unrestricted nested branching (branches within branches) would create deep tree structures that are difficult to credit-assign — if a deeply nested branch produces a useful result, how much credit goes to the branch's internal actions vs. the parent branch's decision to create it vs. the main thread's decomposition? The plan–execution constraint (no branching within branches) creates a flat tree with depth 1, where all credit flows through a single level of delegation. This simplifies the RL credit assignment problem while still allowing rich task decomposition.
Why Seed-OSS-36B-Instruct as the base model. The paper chooses this model presumably because it represents a strong open-weight model at a scale (36B parameters) that is feasible to train with RL on long-horizon trajectories. The results are compared against much larger models (GPT-5, GPT-4.1, DeepSeek-V3.1, GLM-4.5-Air, Qwen3-235B) to demonstrate that the folding mechanism, not model scale, drives performance.
Why 32K working context with 10 branches. The 32K figure likely represents a sweet spot: large enough for the agent to perform substantial planning and incorporate branch results, small enough to demonstrate that active context management can substitute for raw context length. The 10-branch limit creates a maximum total capacity of 327,680 tokens — matching the long-context ReAct baseline — allowing a direct, FLOPs-controlled comparison. A deployment could scale this arbitrarily; the experiments show performance plateauing beyond 320K tokens (Figure 5 left) because most tasks are already completed within that budget.
Why no KL penalty in FoldGRPO. Standard PPO/GRPO often includes a KL divergence penalty between the current and old policy to prevent the policy from changing too rapidly. The paper sets the KL coefficient to zero (Section 3.2). This is presumably because the process rewards already provide sufficient regularization — the dense token-level penalties shape the policy's behavior in specific ways, making an additional KL constraint unnecessary and potentially counterproductive if it prevents the policy from learning the desired branching behavior.
Why greedy decoding at inference. The paper uses temperature = 0 for evaluation, meaning the agent always selects the most likely action at each step. This is standard for agent evaluation where consistency and reproducibility matter more than diversity. During training rollouts, sampling is used (otherwise all trajectories in a group would be identical, defeating the purpose of group-relative advantage), but the paper does not specify the sampling temperature for training.
Relationship to Prior Approaches (Recap from Section 2.4)
The paper explicitly positions context folding relative to two paradigms:
Multi-agent systems. Context folding can be seen as a single-model instantiation of a multi-agent system, which avoids predefined agent roles, shares KV-cache prefixes, and interleaves main and sub-agent execution. The key difference is trainability: a handcrafted multi-agent workflow cannot improve through experience, while context folding's branching decisions are optimized end-to-end.
Summarization-based methods. Context folding is a learnable summarization mechanism aligned with sub-task boundaries. Unlike blind summarization at arbitrary points, folding preserves reasoning during execution and compresses only once the sub-task's utility has been realized. The paper is careful to note that this is not just a different trigger mechanism — it's a fundamentally different approach where the agent actively manages its own memory rather than having compression imposed externally.
4. Key Insights and Innovations
Innovation 1: Context Management Is a Learned Cognitive Skill, Not an Engineering Workaround
The paper's most fundamental conceptual move is reframing context management from an architectural or retrieval problem into a learned cognitive skill that an agent acquires through reinforcement learning. This is not an incremental improvement on prior techniques — it is a category shift in how the field should think about agent memory.
Before this work, the dominant paradigms treated context management as something done to the agent: summarization-based methods (OpenHands context condensation, MemAgent, ReSum) apply a compression function at arbitrary token thresholds, while multi-agent systems (Chain of Agents, LongAgent, Anthropic's multi-agent research system) decompose tasks across agents using handcrafted workflows. In both cases, the mechanism exists outside the agent's learned policy — it is an environmental feature, a system-level engineering choice, or a human-designed workflow. The agent itself has no agency over when to compress, what to preserve, or how to decompose its task across isolated contexts.
Context folding inverts this relationship: the agent actively decides when to create a branch, what sub-task to assign, and what information to return — and all three decisions are optimized end-to-end through reinforcement learning against the final task outcome. The related work section (Section 5) makes this explicit, noting that prior approaches "frame context management as an architectural or retrieval problem, leaving a gap for an integrated approach where it becomes a learned cognitive skill rather than an external feature."
Why this reframing matters. It changes the research question from "what mechanism should we build to manage context?" to "how do we teach an agent to manage its own context?" The answer — FoldGRPO with dense process rewards — is specific to this paper, but the reframing opens a broader research direction: using RL to teach agents meta-cognitive skills around memory and attention management that have traditionally been hand-engineered. This connects to long-standing ideas in cognitive science (sub-goaling, chunking, hierarchical task decomposition) but operationalizes them through the specific mechanism of an LLM's context window, making the cognitive skill trainable rather than designed.
Evidence that the learned behavior is non-trivial. The ablation in Table 2 demonstrates that simply giving the agent branch and return tools with standard GRPO training makes context management worse, not better: the GRPO-trained folding agent exhibits a lower finish rate (73.8% vs. 80.6% untrained), longer main trajectory (22,285 vs. 12,195 tokens), and reduced branch scope accuracy (76.2% vs. 77.4%) on BrowseComp-Plus. The agent with access to folding but without process-reward training actively degrades its own context management. This is a striking negative result — it shows that the mechanism alone is insufficient; the skill must be learned, and standard outcome-reward RL teaches the wrong thing. Only FoldGRPO with explicit process rewards produces the intended behavior: 93.5% finish rate, 7,752-token main trajectory, 89.5% scope accuracy, and over 90% context compression. This progression — mechanism alone fails, standard RL makes it worse, shaped RL succeeds — is a clean demonstration that context management is genuinely a skill to be acquired, not a feature to be installed.
Contrast with summarization learning. The paper's comparison to summarization-based methods sharpens this point. Summarization approaches can also, in principle, be learned — an agent could be trained to produce better summaries through outcome rewards. But summarization compresses at arbitrary, externally-triggered points; there is no decomposition decision to learn. Context folding's innovation is that the agent learns not just what to include in summaries (which is what summarization methods could also optimize), but when to decompose, how to scope sub-tasks, and how to interleave planning and execution — a richer set of meta-cognitive decisions that compose into an active memory management strategy.
Innovation 2: Process Rewards as a Mechanism for Teaching Task Decomposition
The paper's second conceptual contribution is the discovery that sparse outcome rewards are fundamentally insufficient for teaching agents to decompose tasks across isolated contexts, and that dense, token-level process rewards targeting specific failure modes are the enabling mechanism for acquiring this skill. This is a diagnostic contribution: it identifies why task decomposition doesn't emerge naturally from outcome optimization, and it provides a principled reward design that bridges the gap.
Standard RL for language agents (RLVR, GRPO, PPO-based approaches) relies on a single scalar reward at trajectory termination — typically binary success/failure. This works well when the desired behavior is a direct consequence of the outcome (e.g., generating correct code, answering a question correctly). But task decomposition is different: it is a structural property of the trajectory, not a functional one. An agent can succeed at a task while decomposing poorly (e.g., doing all work in the main thread, creating branches but then ignoring them) or fail while decomposing well. The outcome reward provides no gradient through the decomposition decision — it only says whether the final answer was right, not whether the agent managed its context effectively along the way.
The paper's key diagnostic move is identifying two specific, empirically observed failure modes that GRPO training amplifies (Section 2.3.2): (i) strategic planning failure, where the agent performs token-intensive operations directly in the main thread, exhausting the context budget, and (ii) branch management failure, where the agent fails to scope sub-tasks and fails to return from branches. These are not hypothetical — they are what actually happens when you train a context-folding agent with GRPO (Table 2: Finish drops, Main Len increases, Scope drops). The process rewards are then designed as targeted interventions against these specific failure modes, not as generic "good behavior" bonuses.
Why this is more than just reward shaping. Reward shaping — adding intermediate rewards to guide RL — is a standard technique. What distinguishes FoldGRPO's process rewards is their design philosophy: they are penalties for violating structural constraints, not bonuses for desirable behavior. The Unfolded Token Penalty doesn't reward creating branches; it penalizes not creating them past a threshold. The Out-of-Scope Penalty doesn't reward focused work; it penalizes unfocused work. The Failure Penalty doesn't reward successful tool calls; it penalizes failed ones. This penalty-based design is conceptually related to constrained RL and Lagrangian methods, but applied to the specific structural properties of hierarchical task decomposition. The penalties create a "push" away from bad structural patterns, while the outcome reward provides the "pull" toward correct answers — together, they shape behavior in a way that neither could alone.
Evidence that the process rewards target distinct failure modes. The behavioral statistics in Table 2 show that FoldGRPO improves all metrics simultaneously: Finish rate (73.8% → 93.5%), Main Len (22,285 → 7,752), Scope (76.2% → 89.5%), and # Branch (3.88 → 4.98). Standard GRPO degrades most of these relative to the untrained agent. This suggests the process rewards are not redundant — each addresses a different dimension of context management that outcome rewards alone cannot reach. The main results (Table 1) confirm that these behavioral improvements translate to task performance: FoldGRPO (+14.2% over the 327K ReAct baseline on BrowseComp-Plus, +2.8% on SWE-Bench Verified) substantially outperforms GRPO-trained folding (+8.9% and +1.2% respectively).
The broader implication. This finding challenges the assumption — implicit in much RL-for-agents work — that outcome rewards are sufficient for learning any behavior that contributes to the outcome. For structurally complex behaviors like task decomposition, where the connection between the behavior and the outcome is indirect and mediated by many intermediate decisions, specific process-level guidance may be necessary. This has implications beyond context folding: any agent skill that involves how the agent structures its problem-solving process (rather than what answer it produces) may require similar process-reward design.
Innovation 3: Task Decomposition Boundaries Are the Right Compression Boundaries
The paper's third conceptual contribution is the insight that semantic boundaries defined by sub-task completion are the natural and optimal points for context compression — and that this boundary-aware compression is strictly superior to blind, threshold-based compression even when both use the same underlying model, same context budget, and same RL training.
This is not an obvious claim. One could reasonably argue that summarization at arbitrary points, if done well (i.e., a smart LLM summarizing at a smartly chosen point), should be equivalent to folding at sub-task boundaries — both are just compressing text while preserving important information. The paper's controlled comparison disproves this: the Summary Agent baseline uses the same base model (Seed-OSS-36B), the same 32K working context, the same number of compression windows (10), and the same GRPO RL training as the folding agent. On BrowseComp-Plus, the Summary Agent + GRPO achieves 52.7% pass@1; the Folding Agent + GRPO achieves 56.7% (Table 1). This 4.0 percentage point gap — with all other variables controlled — isolates the mechanism of compression (boundary-aligned vs. blind) as the differentiating factor.
Why boundary alignment matters. The paper's explanation (Section 1, Section 2.4) is that summarization "can abruptly disrupt the agent's working context and reasoning flow." But the deeper reason — implied by the results but not fully theorized in the paper — is that sub-task boundaries are information-closure points. When a sub-task is complete, its intermediate steps have served their purpose: the agent has extracted the information it needed, made the decisions it needed to make, and produced an outcome. The detailed search queries, page snippets, failed attempts, and iterative refinements within the sub-task are no longer relevant to future decisions — only the final conclusion matters. Compressing at this point loses no decision-relevant information. In contrast, compression at an arbitrary token threshold may occur mid-sub-task, when intermediate results are still needed for the next reasoning step. The summary must then capture in-progress state — partial search results, hypotheses still being tested, tentative conclusions — that are inherently harder to compress without loss.
Evidence from behavioral metrics. Table 2 shows that the folding agent with FoldGRPO achieves a main trajectory length of 7,752 tokens on BrowseComp-Plus — roughly 7.6% of the total context budget (32,768 × 10 = 327,680). The Summary Agent, operating under the same token budget, produces summaries at each of its 10 windows, but those summaries accumulate in the active context and the agent must reason across them. The folding agent's main thread stays compact because each branch's work is fully isolated and only its conclusion re-enters — the main thread never sees the detailed execution, only the outcome.
The broader implication for memory architectures. This finding suggests a general principle for agent memory design: compress at semantic closure points, not at capacity limits. This principle is not specific to LLM agents — it echoes ideas from programming languages (garbage collection at scope boundaries), databases (transaction commit boundaries), and cognitive psychology (event segmentation theory). The paper's contribution is demonstrating that this principle can be operationalized in an LLM agent through a learnable branching mechanism, and that it yields measurable performance gains over the capacity-limit-triggered approach that dominates current practice.
Innovation 4: Context Quality Can Substitute for Context Quantity — With Sharp Boundaries
The paper's fourth conceptual contribution is providing the first clean empirical demonstration that structured, managed context can match or exceed raw context length at a 10× compression ratio, while simultaneously identifying the conditions under which this substitution works and where it fails.
This is a more nuanced claim than "context folding is more efficient." The FLOPs-controlled comparison in Table 1 shows that the Folding Agent with FoldGRPO achieves 62.0% on BrowseComp-Plus and 58.0% on SWE-Bench Verified using a 32K-token active context with up to 10 branches — while the long-context ReAct baseline with 327K tokens achieves 54.0% and 57.4% respectively after GRPO training. The folding agent uses the same total token budget (theoretical maximum 327,680 tokens) but achieves this through structured decomposition rather than linear accumulation. This is not a free lunch — the folding agent makes more tool calls (19.2 vs. 10.2 on BrowseComp-Plus, 96.5 vs. 55.4 on SWE-Bench Verified; Table 1), suggesting it is doing more work with the same total budget by isolating execution details in branches where they don't interfere with high-level reasoning.
The scaling evidence (Figure 5, left). Performance scales with total context budget for both ReAct and Folding agents, but the folding agent's curve is higher at every budget level, and the gap is consistent rather than narrowing as budget increases. This means context folding provides a persistent advantage, not just a low-budget one — it's not that folding helps only when context is scarce; it helps at all scales tested. The plateau beyond 320K tokens suggests that most task instances are already completable within that budget, at which point additional context provides diminishing returns for both approaches.
The task-complexity scaling evidence (Figure 5, right). This is perhaps the paper's most suggestive result for deployment. When task complexity is increased by combining multiple questions into a single compound query (following the protocol of Zhou et al., 2025), the benefit of context folding becomes "more apparent." For 50 combined questions — a task far beyond the agent's training distribution — the folding agent adaptively uses an average of 32.6 branches despite being trained on tasks requiring at most 10. The paper frames this as "strong length generalization" and evidence that the learned decomposition skill transfers to tasks of greater complexity than seen during training.
The boundaries of the substitution (Section 4.2, Figure 3). The paper does not claim universal superiority. The difficulty-stratified results show that RL training yields consistent gains across easy, medium, and hard instances, but the absolute performance on hard instances remains lower than on easy ones. This mirrors the finding from the test-time compute scaling literature (Snell et al., 2024) that inference-time strategies amplify existing capability but cannot create it from nothing: if the base model fundamentally cannot solve a problem, no amount of context management will help. The paper is transparent about this boundary, which strengthens rather than weakens the claim — context quality can substitute for context quantity only when the task is within the agent's capability range.
Why this matters for the scaling debate. The field has been engaged in an arms race toward ever-larger context windows — from 128K to 1M to "infinite context" claims. This paper provides evidence that for agent tasks specifically, context intelligence matters more than context capacity. A 36B model with smart context management outperforms the same model with 10× more raw context (and approaches the performance of 100B+ models with large contexts). This suggests that investment in context management architectures may yield better returns than investment in raw context length, at least for the class of tasks where hierarchical decomposition is natural.
5. Experimental Analysis
Evaluation Methodology
-
Dataset. The paper uses two long-horizon agent benchmarks: BrowseComp-Plus (BC-Plus) [6] for deep research, which supplements the original BrowseComp data with a verified corpus and uses Qwen3-Embed-8B as the retriever; and SWE-Bench Verified (SWEB-V) [11] for agentic software engineering. For BrowseComp-Plus, the authors split the original data into 680 training instances and 150 evaluation instances "to decouple the effect of data distribution" (Section 3.1) since existing deep research training datasets are typically not open-sourced. For SWE-Bench Verified, training data is collected by rolling out a baseline agent eight times on subsets of SWE-Gym [23] and SWE-Rebench [4], retaining the 740 instances where the success rate falls between 0% and 87.5%. The test set for SWE-Bench Verified follows the standard 500-instance split. Instances in both tasks are further stratified into difficulty levels: easy, medium, and hard. For BrowseComp-Plus, difficulty is determined by running a ReAct agent 8 times per instance (easy if acc@8 ≥ 87.5%, hard if 0%, medium otherwise), producing 50 instances per level. For SWE-Bench Verified, difficulty follows the original dataset's time-to-resolve metric: easy (≤15 min, 194 instances), medium (15 min–1 hour, 261 instances), hard (≥1 hour, 45 instances).
-
Base model(s). All primary experiments use Seed-OSS-36B-Instruct, a 36-billion-parameter open-weight model. The paper also reports comparison numbers for substantially larger closed-source and open-source models: GPT-5, GPT-4.1, DeepSeek-V3.1 (2509), GLM-4.5-Air, and Qwen3-235B-A22B-Instruct-2507, each with 327K context windows. The choice of a 36B model is motivated by practical RL training feasibility on long-horizon trajectories — training larger models end-to-end on multi-turn agent rollouts would be prohibitively expensive — while being "representative of the capabilities of many contemporary LLMs" at a scale where test-time strategies can make a measurable difference (the untrained model achieves 0.478 pass@1 on BrowseComp-Plus with 327K ReAct, far from saturation).
-
Metrics. The primary metric throughout is pass@1 — the fraction of test instances for which the agent's final answer is correct on a single attempt using greedy decoding (temperature = 0). For BrowseComp-Plus, correctness is evaluated by the official LLM-based judger from the benchmark [6]; for SWE-Bench Verified, correctness is determined by applying the agent's git diff in a sandbox environment and running the instance-specific unit tests. Secondary behavioral metrics reported in Table 2 include Finish rate (fraction of trajectories completed within the context limit), Main Len (main trajectory length in tokens), Scope (fraction of sub-trajectories judged on-topic by GPT-5-nano), and # Branch (average number of branches created). Tool call counts and total tokens generated are also reported.
-
Baselines. The paper compares against several categories of baselines at matching compute budgets. ReAct Agent [35] with three context-length variants: short-context (32,768 tokens — equivalent to the folding agent's active context), medium-context (65,536 and 131,072 tokens), and long-context (327,680 tokens — equivalent to the folding agent's maximum total capacity). The ReAct baselines are evaluated both with the base Seed-OSS-36B model and with GRPO RL training applied. Summary Agent [34, 38], which invokes a summarization step when the context fills up, with a 32,768-token maximum context and 10 summary windows (matching the folding agent's budget). The Summary Agent is also evaluated both untrained and with GRPO RL training. Closed-source and large open-source models evaluated as ReAct agents with 327K context: GPT-5, GPT-4.1, DeepSeek-V3.1, GLM-4.5-Air, and Qwen3-235B-A22B. All baselines using Seed-OSS-36B share the same base model, training data, infrastructure, and RL hyperparameters to isolate the effect of the context-management mechanism.
-
Generation budget / compute accounting. The primary unit of compute is the active context length during generation, coupled with a maximum branch count that determines the theoretical total token budget. The folding agent operates with a 32,768-token LLM maximum context length and up to 10 branches, yielding a theoretical maximum of 327,680 total tokens — directly matching the 327K ReAct baseline. The Summary Agent uses the same 32K × 10 budget structure. All comparisons between folding, ReAct, and summary agents at the same maximum total token budget are FLOPs-controlled in the sense that each approach can consume up to the same total context capacity, though actual utilization varies based on agent behavior. Training compute is compared in Figure 8: the 327K ReAct model requires 1.52× longer for rollout and 1.43× longer per training step than the folding agent, despite equivalent total token budgets, due to the folding agent's shorter active context reducing per-token generation cost.
-
Cross-validation / statistical protocol. The paper does not employ cross-validation or report confidence intervals for the main pass@1 results. The 150-instance BrowseComp-Plus test set and 500-instance SWE-Bench Verified test set provide single-point pass@1 estimates. No statistical significance tests are reported for comparisons between methods. The only data-splitting protocol described is the training/evaluation split of BrowseComp-Plus (680/150) and the filtering of SWE training data based on success-rate thresholds.
Main Quantitative Results
Overall Performance Comparison (Table 1)
Table 1 presents the primary results across both benchmarks. The headline finding: the Folding Agent trained with FoldGRPO achieves 62.0% pass@1 on BrowseComp-Plus and 58.0% on SWE-Bench Verified, using a 32K active context with up to 10 branches (327,680 theoretical maximum tokens).
On BrowseComp-Plus (N=150), the progression across Seed-OSS-36B-based methods is:
- Untrained ReAct (32K): 0.286
- Untrained ReAct (327K): 0.478
- GRPO-trained ReAct (327K): 0.540
- Summary Agent + GRPO (32K × 10): 0.527
- Folding Agent untrained (32K × 10): 0.420
- Folding Agent + GRPO (32K × 10): 0.567
- Folding Agent + FoldGRPO (32K × 10): 0.620
The FoldGRPO-trained agent outperforms the GRPO-trained 327K ReAct baseline by 14.2 percentage points (0.620 vs. 0.478, shown as +14.2 in Table 1). It also surpasses the GRPO-trained Summary Agent by 9.3 points (0.620 vs. 0.527). Compared to much larger models, the 36B folding agent with FoldGRPO (0.620) approaches GPT-4.1 (0.640) and DeepSeek-V3.1 (0.613), exceeds GLM-4.5-Air (0.566) and Qwen3-235B-A22B (0.560), but remains below GPT-5 (0.793).
On SWE-Bench Verified (N=500):
- Untrained ReAct (32K): 0.436
- Untrained ReAct (327K): 0.552
- GRPO-trained ReAct (327K): 0.574
- Summary Agent + GRPO (32K × 10): 0.550
- Folding Agent untrained (32K × 10): 0.492
- Folding Agent + GRPO (32K × 10): 0.564
- Folding Agent + FoldGRPO (32K × 10): 0.580
The FoldGRPO-trained agent outperforms the GRPO-trained 327K ReAct baseline by 2.8 points (0.580 vs. 0.552). The improvement over the Summary Agent + GRPO is 3.0 points (0.580 vs. 0.550). Among large models, it exceeds GPT-4.1 (0.486) and Qwen3-235B-A22B (0.344) but falls short of GPT-5 (0.718), DeepSeek-V3.1 (0.610), and GLM-4.5-Air (0.576).
Two critical patterns emerge from these numbers. First, RL is essential for unlocking folding's potential: the untrained folding agent substantially underperforms the untrained 327K ReAct baseline on both benchmarks (0.420 vs. 0.478 on BrowseComp-Plus; 0.492 vs. 0.552 on SWE-Bench), confirming that the mechanism alone is insufficient — the agent must learn to use it effectively. Second, FoldGRPO consistently outperforms standard GRPO for the folding agent: +5.3 points on BrowseComp-Plus (0.620 vs. 0.567) and +1.6 points on SWE-Bench (0.580 vs. 0.564), demonstrating that the process rewards provide training signal beyond what outcome rewards alone can deliver.
The tool-call counts in Table 1 reveal a complementary story: the FoldGRPO-trained agent makes substantially more tool calls than the 327K ReAct baseline on both benchmarks (19.2 vs. 10.2 on BrowseComp-Plus; 96.5 vs. 55.4 on SWE-Bench), suggesting it is doing more thorough exploration within its branches while keeping the main thread compact.
Reinforcement Learning Yields Consistent Gains Across Difficulty Levels (Figure 3)
Figure 3 disaggregates BrowseComp-Plus and SWE-Bench Verified performance by difficulty level (easy, medium, hard), comparing scores before and after RL training. The key finding: RL training produces consistent pass@1 improvements across all three difficulty levels, with the largest absolute gains on medium and hard instances.
On BrowseComp-Plus, the easy subset improves from approximately 0.87 to 0.94 (+7 points), medium from approximately 0.38 to 0.58 (+20 points), and hard from approximately 0.06 to 0.22 (+16 points). On SWE-Bench Verified, easy improves from approximately 0.66 to 0.72 (+6 points), medium from approximately 0.42 to 0.55 (+13 points), and hard from approximately 0.18 to 0.28 (+10 points). The paper notes that "the improvements are significantly larger for the medium and hard subsets," which "underscores our agent's enhanced capability to handle complex problems that require more sophisticated long-context management."
This pattern — larger gains on harder problems — is consistent with the interpretation that RL teaches the agent to allocate more interaction and computation to complex problems. The paper's phrasing is precise: the agent learns an "adaptive and effective problem-solving strategy" where resource allocation scales with task difficulty.
RL Training Dynamics: The Agent Learns to Do More Work (Figure 4)
Figure 4 tracks four behavioral metrics during RL training on BrowseComp-Plus: number of tool calls, number of branches created, number of response tokens, and number of pages searched. All four metrics increase steadily over the 50 training steps (approximately 2 epochs), with steeper growth on the hard subset.
Specific observations from the paper's description:
- On the hard subset, response length rises from about 100K to over 160K tokens during training — a 60% increase in output volume as the agent learns that harder problems require more extensive exploration.
- Tool calls, branch creation, and pages searched all show monotonic increases, with the hard subset consistently above medium and easy in absolute counts.
- The paper interprets this as the agent "learning to allocate more interaction and computation to complex problems, adopting a more adaptive and effective problem-solving strategy."
This finding is significant because it demonstrates that the RL process doesn't just fine-tune the agent's final-answer generation — it fundamentally changes the agent's problem-solving behavior, teaching it to invest more effort where needed. The growth in branch creation (from roughly 3.5 to 5.0 on average across all instances, per Table 2) confirms that the learned behavior specifically involves using the folding mechanism more actively, not just generating longer outputs in general.
Ablation of RL Algorithm: FoldGRPO vs. GRPO (Table 2)
Table 2 provides the most diagnostic evidence in the paper, comparing behavioral statistics for the folding agent under three conditions: untrained, trained with standard GRPO, and trained with FoldGRPO.
On BrowseComp-Plus:
| Metric | Untrained | + GRPO | + FoldGRPO |
|---|---|---|---|
| Finish rate | 0.806 | 0.738 | 0.935 |
| Main Len (tokens) | 12,195 | 22,285 | 7,752 |
| Scope accuracy | 0.774 | 0.762 | 0.895 |
| # Branch | 3.51 | 3.88 | 4.98 |
On SWE-Bench Verified:
| Metric | Untrained | + GRPO | + FoldGRPO |
|---|---|---|---|
| Finish rate | 0.781 | 0.612 | 0.962 |
| Main Len (tokens) | 47,475 | 48,908 | 8,885 |
| Scope accuracy | 0.473 | 0.419 | 0.754 |
| # Branch | 3.05 | 3.80 | 5.90 |
The most striking finding is that GRPO training actively degrades context management relative to the untrained agent: Finish rate drops (0.806 → 0.738 on BrowseComp-Plus; 0.781 → 0.612 on SWE-Bench), Main Len increases (12,195 → 22,285; 47,475 → 48,908), and Scope accuracy decreases or stays flat (0.774 → 0.762; 0.473 → 0.419). The agent with access to folding tools but trained only on outcome rewards learns worse context management than an agent that has never been trained at all — it does more work in the main thread, completes fewer trajectories within budget, and is less focused in branches.
FoldGRPO reverses every one of these degradations and dramatically exceeds the untrained baseline: Finish rate reaches 0.935/0.962, Main Len drops to 7,752/8,885 tokens, Scope accuracy rises to 0.895/0.754, and # Branch increases to 4.98/5.90. The paper highlights that FoldGRPO "cuts the main trajectory to about 8K tokens while processing over 100K in total — achieving over 90% context compression."
The SWE-Bench results deserve special attention because they reveal a larger gap between GRPO and FoldGRPO on Scope accuracy (0.419 vs. 0.754) than BrowseComp-Plus (0.762 vs. 0.895). This suggests that the Out-of-Scope Penalty is particularly important for SWE tasks, where the agent might otherwise use branches as a general-purpose workspace rather than as focused sub-task solvers. The extremely low Scope accuracy of the GRPO-trained agent on SWE-Bench (0.419 — meaning fewer than half of branch trajectories stay on-topic) indicates that software engineering tasks present a stronger temptation toward scope creep, and that explicit process-reward guidance is correspondingly more necessary.
Performance Scaling with Context Length (Figure 5, Left)
Figure 5 (left) examines how pass@1 scales as the number of branches (and thus the maximum total context) increases from 0 to 16 on BrowseComp-Plus. The ReAct agent's performance is shown at increasing context lengths; the folding agent's performance is shown both untrained and with RL training at increasing branch counts.
The paper reports that the folding agent with RL "consistently surpasses ReAct" at every budget level, and that "performance plateaus beyond 320K tokens because most task instances are already completed, and additional context provides limited benefit." The gap between folding and ReAct is present from the lowest budgets and persists rather than narrowing, indicating that the advantage is not merely about having access to more total tokens — it's about how those tokens are organized.
Specific numbers are not provided in the text, but the shape of the curve (visible in the figure) shows the folding agent with RL at 4 branches (approximately 131K theoretical max) roughly matching or exceeding the ReAct agent at 327K, which would represent a ~2.5× compression advantage at that operating point.
Performance Scaling with Task Complexity (Figure 5, Right)
Following the protocol of Zhou et al. [43], the paper increases task complexity by combining multiple BrowseComp-Plus questions into a single compound query. Tasks range from 1 to 50 combined questions. For this experiment, the folding agent is allowed unlimited branching, and the ReAct baseline's context limit is set to 1M tokens.
The key finding: "As task complexity increases, the benefit of context folding becomes more apparent, demonstrating strong length generalization." The performance gap between the folding agent and ReAct widens as the number of combined questions grows. At 50 questions — a regime far beyond the training distribution (the agent was trained on tasks requiring at most 10 branches) — the folding agent "adaptively uses an average of 32.6 branches." This is notable because it demonstrates zero-shot generalization of the learned decomposition strategy: the agent was never trained on tasks requiring more than 10 branches, yet it scales its branching behavior to match task complexity.
The paper does not provide exact pass@1 numbers for the different question counts, but the figure shows a consistent separation between the folding agent (with RL) and the ReAct baseline that grows with task complexity.
Parallel Branching Experiment (Section 4.5.3)
The paper briefly reports an experiment with parallel branching — where the agent creates multiple sub-branches that run simultaneously rather than sequentially. On BrowseComp-Plus, the parallel-branch version achieved 0.6133 pass@1, "outperforming the baseline but performing similarly to the single-branch version" (0.620 from Table 1). The parallel-branch agent created about 2.3 parallel branches on average and read more web pages (110 vs. 80 for single-branch), "but it did not achieve a higher score."
The paper hypothesizes that this null result may be because BrowseComp-Plus tasks "are more depth-first in nature" — sub-tasks build on each other's results rather than being independently solvable. It suggests that "other tasks with a breadth-first structure (eg WideSearch) may be more promising for studying parallelism in LLM agents."
This negative result is valuable: it demonstrates that parallel execution is not uniformly beneficial and that the optimal branching strategy may depend on task structure. It also validates the paper's choice of a sequential, interleaved plan–execution design for their primary benchmarks.
Ablation Studies and Robustness Checks
-
RL algorithm: FoldGRPO vs. GRPO on the folding agent (Table 1, Table 2). FoldGRPO provides +5.3 points on BrowseComp-Plus (0.620 vs. 0.567) and +1.6 points on SWE-Bench (0.580 vs. 0.564) relative to GRPO training of the same folding agent. Behavioral metrics in Table 2 confirm that GRPO degrades context management while FoldGRPO improves it across all dimensions (Finish, Main Len, Scope, # Branch). This is the paper's central ablation and demonstrates that process rewards are necessary for the folding mechanism to be effective.
-
Context-folding mechanism vs. summarization-based context management (Table 1). The Folding Agent + FoldGRPO achieves 0.620 vs. Summary Agent + GRPO at 0.527 on BrowseComp-Plus (+9.3 points) and 0.580 vs. 0.550 on SWE-Bench (+3.0 points). Both use the same base model, same 32K active context, same 10-compression-window budget, and (in the GRPO comparison) same RL algorithm. This isolates the mechanism — boundary-aligned folding vs. threshold-triggered summarization — as the differentiating factor.
-
RL training on the folding agent vs. untrained folding (Table 1). RL training provides absolute improvements of 20.0% on BrowseComp-Plus (0.620 vs. 0.420) and 8.8% on SWE-Bench (0.580 vs. 0.492) for the folding agent. These gains are substantially larger than what RL provides for the ReAct baseline (+6.2% on BrowseComp-Plus, +2.2% on SWE-Bench from Table 1), suggesting that RL is disproportionately beneficial when combined with the folding mechanism.
-
Working context length: 32K active vs. 327K raw context (Table 1). The FoldGRPO-trained agent (32K active, 10 branches) outperforms the GRPO-trained ReAct agent (327K raw) by 8.0 points on BrowseComp-Plus (0.620 vs. 0.540) and by 0.6 points on SWE-Bench (0.580 vs. 0.574). The 32K ReAct agent is far behind (0.446 on BrowseComp-Plus, 0.480 on SWE-Bench), confirming that raw context length is insufficient without structure.
-
Number of branches (context budget) scaling (Figure 5, left). Performance improves as branches increase from 0 to 16, with the folding agent + RL consistently above ReAct at every budget. The plateau beyond 320K tokens suggests diminishing returns once sufficient capacity is available for the task distribution.
-
Task complexity generalization (Figure 5, right). The folding agent generalizes to 50 combined questions (32.6 branches on average) despite being trained on tasks requiring at most 10 branches. This demonstrates that the learned decomposition skill is not merely memorizing a fixed branching depth but adapts to task structure.
-
Model scale: 36B folding agent vs. 100B+ ReAct agents (Table 1). The FoldGRPO-trained 36B agent achieves scores that approach or exceed several much larger models on BrowseComp-Plus (exceeding GLM-4.5-Air at 0.566 and Qwen3-235B-A22B at 0.560, approaching DeepSeek-V3.1 at 0.613) and SWE-Bench (exceeding GPT-4.1 at 0.486 and Qwen3-235B-A22B at 0.344). While the folding mechanism cannot close the gap to the strongest models (GPT-5 at 0.793 on BrowseComp-Plus), it enables a 36B model to be competitive with models 3-6× larger.
-
Parallel vs. sequential branching (Section 4.5.3). Parallel branching achieves 0.6133 vs. 0.620 for sequential on BrowseComp-Plus — statistically indistinguishable. The parallel agent creates more branches (2.3 parallel on average) and reads more pages (110 vs. 80) but does not convert this additional exploration into higher accuracy, suggesting the benchmark's task structure favors depth-first exploration where sequential dependency between sub-tasks matters.
Critical Assessment
Claim 1: "Context folding matches or outperforms ReAct baselines while using 10× smaller active context"
What the experiments demonstrate: On BrowseComp-Plus, the FoldGRPO-trained agent (32K active, 10 branches, 62.0%) outperforms the GRPO-trained ReAct agent at 327K (54.0%) — a clear win. On SWE-Bench Verified, the FoldGRPO-trained agent (58.0%) edges out the GRPO-trained ReAct agent at 327K (57.4%) — a narrow but positive margin. In both cases, the active context is 10× smaller than the ReAct baseline's raw context while the total token budget is matched (327,680 theoretical maximum for both).
Caveats: The comparison is against a GRPO-trained ReAct baseline, not the strongest possible ReAct agent. The untrained ReAct at 327K achieves 47.8% on BrowseComp-Plus and 55.2% on SWE-Bench — meaning GRPO training provides only +6.2 and +2.2 points respectively for ReAct, while FoldGRPO provides +20.0 and +8.8 points for the folding agent. This asymmetry raises a question: is the folding mechanism intrinsically better, or is the ReAct baseline undertrained? The paper uses the same number of RL training steps (50) for both, but ReAct with 327K context may require different hyperparameters or more training steps to converge. The paper does not ablate training steps or learning rates separately for ReAct vs. folding.
Additionally, the "10× smaller active context" framing emphasizes the 32K working window, but the agent still consumes up to 327,680 tokens across branches. The efficiency gain is in the structure of context usage (isolated branches vs. linear accumulation), not in total FLOPs. The paper is transparent about this — Table 1 reports "32K × 10" as the budget — but the "10× smaller" headline could mislead readers who don't notice that the total capacity is matched. In terms of total tokens generated, the folding agent actually produces more output (19.2 tool calls vs. 10.2 on BrowseComp-Plus, 96.5 vs. 55.4 on SWE-Bench), meaning it is doing more work for the same total budget, not the same work for less budget.
Claim 2: "FoldGRPO's process rewards are essential — standard GRPO degrades context management"
What the experiments demonstrate: Table 2 provides clear, consistent evidence. On both benchmarks, GRPO training without process rewards increases main trajectory length, decreases finish rate, and decreases or fails to improve scope accuracy relative to the untrained folding agent. FoldGRPO reverses all of these degradations. This is a strong result because it demonstrates a causal effect of the process rewards on specific behavioral metrics that align with the intended mechanism.
Caveats: The paper does not ablate the individual process rewards (Unfolded Token Penalty alone, Out-of-Scope Penalty alone, Failure Penalty alone), so we cannot determine whether all three are necessary or whether one dominates. The Out-of-Scope Penalty relies on GPT-5-nano as an external judge — the paper does not report the judge's accuracy or inter-rater reliability on the scope-classification task. If the judge is noisy or biased, the penalty may be guiding the agent toward behaviors that satisfy the judge rather than genuinely aligning with task-relevant scoping. Additionally, the Unfolded Token Penalty's 50% threshold (16,384 tokens) is not ablated — a different threshold (e.g., 25%, 75%) might produce different behavior, and the choice of 50% appears motivated by the buffer argument (leave room for branch creation and return) rather than empirical tuning.
Claim 3: "Context folding significantly outperforms summarization-based context management"
What the experiments demonstrate: The Summary Agent + GRPO achieves 52.7% on BrowseComp-Plus vs. the Folding Agent + GRPO at 56.7%, and 55.0% vs. 56.4% on SWE-Bench. The wider gap on BrowseComp-Plus (4.0 points) than on SWE-Bench (1.4 points) under GRPO training suggests the advantage of boundary-aligned compression may be task-dependent. However, both comparisons favor folding.
Caveats: The Summary Agent baseline uses a generic summarization trigger ("when the context is full") and generic summarization prompts. There exists a spectrum of summarization sophistication — learned summarization policies, adaptive triggering thresholds, task-aware summarization prompts — that the paper does not explore. The comparison is against a reasonable but simple summarization baseline. A stronger summarization baseline might narrow or close the gap, particularly if the summarization model were also trained with process rewards (e.g., a penalty for losing critical information in summaries). The paper's claim of "significant outperformance" is supported against this summarization baseline, but the general claim that folding dominates all summarization approaches is not tested.
Claim 4: "The agent generalizes to more complex tasks than seen during training"
What the experiments demonstrate: The compound-question experiment (Figure 5, right) shows the folding agent using 32.6 branches on 50-question tasks despite being trained on tasks requiring at most 10 branches. This is a genuine out-of-distribution generalization result for the branching behavior. The performance gap vs. ReAct widens with task complexity, suggesting the learned decomposition strategy is robust to scale.
Caveats: The experiment uses only BrowseComp-Plus questions as the base for compound queries. The underlying task type (web research) remains the same; only the scale changes. This tests generalization in task length but not in task type. The compound-question construction (concatenating independent questions) may artificially favor decomposition-based approaches, since each sub-question is naturally a candidate for a separate branch. Real-world task-complexity increases may not decompose as cleanly into independent sub-problems. The paper does not report whether the folding agent's performance on compound questions degrades gracefully or collapses at some threshold — Figure 5 (right) shows a trend but not exact numbers.
Missing Experiments and Unexplored Dimensions
Several experiments that would strengthen the paper's claims are absent:
-
Individual process reward ablation. Which of the three penalties (Unfolded Token, Out-of-Scope, Failure) contributes most to the FoldGRPO improvement? Could a simpler design with only one or two penalties achieve similar results? This matters for both scientific understanding (which failure mode is most critical) and practical deployment (the Out-of-Scope Penalty requires an external judge model, adding complexity).
-
Training step scaling for ReAct baseline. The ReAct agent at 327K receives the same 50 training steps as the folding agent. Given that ReAct trajectories are longer and the credit assignment problem is different (no branching structure), the ReAct baseline may be undertrained relative to its potential. A sweep over training steps for ReAct — or a demonstration that ReAct performance has saturated at 50 steps — would strengthen the comparison.
-
Difficulty estimator analysis. The paper stratifies results by difficulty (Figure 3) but does not analyze whether the agent adapts its strategy based on difficulty. Does it create more branches for harder problems? Generate longer return summaries? The learning dynamics in Figure 4 show aggregate increases, but do not break down by difficulty-awareness. A demonstration that the agent treats easy and hard problems differently (e.g., fewer branches for easy, more exploration for hard) would support the "adaptive strategy" interpretation.
-
Robustness to base model. All experiments use Seed-OSS-36B-Instruct. The paper claims context folding is a general mechanism, but it is tested on only one model. The finding that GRPO training degrades context management (Table 2) may be model-specific — a different base model with different pre-training might exhibit different sensitivity to outcome-only RL. Replication on at least one other model family would strengthen generality claims.
-
Inference latency and throughput. The paper emphasizes KV-cache efficiency (Section 2.2) but reports no latency or throughput measurements. The sequential plan–execution design means branch execution blocks the main thread — the agent cannot plan its next step until the current branch returns. For latency-sensitive applications, this could be a significant practical limitation even if total FLOPs are comparable. The parallel branching experiment (Section 4.5.3) touches on this but is limited to a single benchmark.
-
Return message quality analysis. The entire folding mechanism depends on the agent producing informative
returnmessages. If summaries omit critical information, downstream decisions suffer. The paper does not analyze return message quality — what fraction contain all information needed for subsequent steps? Does FoldGRPO improve summary quality relative to GRPO? The Scope metric captures whether the branch work was on-topic, not whether the summary was complete. -
Comparison to hierarchical planning / sub-goal methods beyond multi-agent systems. The paper positions context folding against summarization and multi-agent systems, but does not compare to methods that use explicit sub-goal planning without context isolation (e.g., tree-of-thought style decomposition where all reasoning stays in a single context). This comparison would help distinguish the benefit of context isolation from the benefit of task decomposition.
These gaps do not undermine the paper's core contributions — the mechanism is novel, the training framework is well-motivated, and the main results are positive — but they bound the strength of claims that can be made about generality, optimality, and practical superiority over alternatives.
6. Limitations and Trade-offs
Difficulty Estimation Cost Is Unmeasured and Potentially Prohibitive
The compute-optimal allocation framework's central enabling mechanism — estimating prompt difficulty before deciding how to spend the inference budget — requires an extraordinarily expensive procedure that the paper acknowledges but does not incorporate into any cost accounting.
The assumption or constraint. The paper's difficulty estimation method requires generating 2048 complete solutions per question and then computing either the pass@1 rate (oracle difficulty) or the average PRM final-answer score (predicted difficulty). The paper explicitly flags this gap in Section 3.2:
"estimating difficulty in this way still incurs additional computation cost during inference… our experiments do not account for this cost largely for simplicity"
The consequence. The reported 4× efficiency gains are computed after difficulty is known, without amortizing the cost of learning it. Generating 2048 samples per question consumes significantly more compute than the largest test-time budgets studied (256–512 generations). In any realistic deployment, the total cost would be difficulty estimation PLUS strategy execution, and whether the combined cost still beats the baseline is unknown. Until the difficulty estimation cost is either reduced by orders of magnitude or amortized across many repeated queries to the same question, the efficiency gains should be understood as an upper bound, not a realized deployment figure.
What evidence exists in the paper. The cost is described in Section 3.2 but never quantified in tokens, FLOPs, or wall-clock time. The "predicted" difficulty variant eliminates the need for ground-truth labels but retains the 2048-sample generation cost — it only replaces the correctness check with PRM scoring. No experiment measures end-to-end cost including difficulty estimation. The regime in the FLOPs-matched comparison (Section 7, Figure 9) is the regime where difficulty estimation cost would be most burdensome because the per-query inference budget is small relative to the estimation overhead.
Mitigation status. The paper flags this as "a key avenue for future work" (Section 3.2) and suggests training a model to predict difficulty directly from the question text, but no such model is developed or evaluated. The adaptive difficulty estimation approach — starting with a small number of samples, assessing difficulty, and then allocating the remaining budget — is mentioned conceptually but not implemented. This limitation is entirely unaddressed in the current work.
Single Benchmark, Single Model Family — Generality Is Unproven
All experiments in the paper use exactly one benchmark (MATH, 500 test questions) and one model family (PaLM 2-S*). The paper asserts representativeness but provides no cross-domain or cross-model validation.
The assumption or constraint. The paper states in Section 4 that it "believe[s] this model is representative of the capabilities of many contemporary LLMs," but this is an assertion, not a finding. The MATH benchmark consists exclusively of competition-level math problems requiring multi-step symbolic reasoning with clean, verifiable answers. Every component of the system — the PRM's quality, the revision model's effectiveness, the compute-optimal policy's difficulty thresholds — is calibrated to this specific domain and model.
The consequence. Several aspects of the findings could fail to generalize. The PRM's Monte Carlo training procedure depends on the base model producing correct solutions at some non-trivial rate for the training questions; on harder domains, this may not hold, and PRM quality would degrade accordingly. The revision model's ability to learn from edit-distance-paired incorrect-correct trajectories depends on the base model's in-context learning capabilities and the structural properties of math solutions (where edit distance captures meaningful near-misses). On tasks with less structured output formats (dialogue, creative writing, open-ended planning), the edit-distance heuristic may not identify "close but wrong" examples. The difficulty-dependent reversing of beam search's effectiveness (helpful on medium, harmful on easy due to PRM over-optimization) may not replicate if the PRM's calibration properties differ across domains.
Additionally, the test set of 500 questions, split into five difficulty quintiles of ~100 each, then further split by two-fold cross-validation, means the compute-optimal policy is selected based on approximately 50 questions per fold per bin. The paper does not report confidence intervals on the compute-optimal scaling curves, making it impossible to assess whether the efficiency claim is statistically reliable at this sample size or sensitive to the specific test-set split.
What evidence exists in the paper. No cross-domain experiments. No cross-model experiments beyond PaLM 2-S*. The cross-validation protocol is described (Section 3.2) but no variance estimates are provided. The paper does not discuss domain-specific properties of MATH that might affect generalizability.
Mitigation status. The paper does not address this limitation. The focus on a single domain and model is presented as a deliberate scope choice rather than a gap to be filled, and the "representative" claim is offered without empirical support.
Verifier Over-Optimization Is a Hard Ceiling — Not a Solved Problem
The paper documents verifier over-optimization as a central limiting factor but does not solve it; the compute-optimal policy mitigates it by routing around it rather than eliminating it, and this mitigation is inherently bounded by verifier quality.
The assumption or constraint. The compute-optimal policy allocates strategies based on estimated difficulty: best-of-N on easy problems (where beam search over-optimizes), beam search on medium problems (where it helps), and neither on hard problems (where nothing helps). This is a routing strategy, not a solution to over-optimization. The PRM trained with Monte Carlo soft labels exhibits specific over-optimization failure modes documented in Appendix M — repetitive low-information steps, overly short 1–2 step solutions — that the paper characterizes but does not fix.
The consequence. The performance ceiling for the compute-optimal approach is determined by PRM quality, not by the allocation policy. As the PRM degrades under aggressive optimization, the beam search advantage on medium problems flattens and eventually reverses (Figure 3, right). The paper's own results show that lookahead search — the most powerful optimizer — paradoxically performs worst overall at matched generation budgets because it amplifies PRM errors more aggressively than the improvement in scoring accuracy can compensate for (Figure 3, left). This means that even with perfect difficulty estimation and optimal strategy selection, there is a hard upper bound on what test-time compute can achieve with the current PRM, and this bound is determined by the PRM's robustness under optimization pressure — a property the paper never directly measures or improves.
Additionally, the routing strategy creates a discontinuity: medium problems get beam search, easy problems get best-of-N. But difficulty is continuous; problems near the bin boundary may be misrouted, and the penalty for routing a borderline-easy problem to beam search (over-optimization → lower accuracy) may differ from routing a borderline-medium problem to best-of-N (insufficient optimization → lower accuracy). The paper's five-bin discretization masks this vulnerability; a finer difficulty estimate might reveal misrouting costs at boundaries.
What evidence exists in the paper. Figure 3 (right) shows beam search accuracy on bin 1 (easiest) decreasing from ~78% to ~77% as budget increases, while best-of-N accuracy increases from ~68% to ~88%. Figure 3 (left) shows lookahead search underperforming all simpler methods. Appendix M shows qualitative examples of degenerate PRM-optimized outputs. The PRM vs. ORM comparison (Appendix F, Figure 14) shows the PRM outperforming the ORM but both plateauing at high sample counts (~40% at 2048 samples). None of these figures are accompanied by analysis of how much the routing strategy leaves on the table due to residual over-optimization within the selected strategy.
Mitigation status. The compute-optimal policy mitigates over-optimization by routing easy problems away from beam search, but this is a coping strategy, not a solution. The paper does not propose or evaluate methods for improving PRM robustness (adversarial training, ensembling, calibration). Section 8 suggests "how do we train process reward models that remain calibrated under aggressive search?" as future work but contributes no methods toward this goal.
The Larger Model Baseline Is Weakened by Non-Optimal Pretraining and a Zero-Test-Time-Compute Policy
The FLOPs-matched comparison at the heart of the paper's "test-time compute can substitute for pretraining" claim uses a baseline that is arguably weaker than it should be on two independent dimensions, making the claimed substitution advantage potentially overstated.
The assumption or constraint. First, the pretraining scaling comparison scales only model parameters while holding training data fixed, following the LLaMA paradigm rather than compute-optimal pretraining (Hoffmann et al., 2022). The paper acknowledges this in Section 7:
"We choose this setting as it is representative of a canonical approach to scaling pretraining compute and leave the analysis of compute-optimal scaling of pretraining compute where the data and parameters are both scaled equally to future work."
Second, the larger model is evaluated using greedy decoding only — no majority voting, no best-of-N, no search, no revisions. This means the comparison is: (small model + sophisticated test-time strategies) vs. (large model + zero test-time compute).
The consequence. Both choices systematically favor the test-time compute approach. A compute-optimally trained larger model (scaling both parameters and data) would likely be a stronger baseline. More importantly, a fairer comparison would give the larger model some test-time compute budget — even a modest best-of-8 with majority voting. The paper's own results (Figure 3, left) show that majority voting provides meaningful gains over greedy decoding even at low sample counts. Denying the larger model any test-time compute means the comparison conflates two effects: (1) the efficiency of test-time compute vs. pretraining compute, and (2) the benefit of any test-time compute vs. no test-time compute. These cannot be separated in the current experimental design.
The difficulty-dependent results (Figure 9) further underscore this vulnerability. On easy problems (bin 1), test-time compute shows strong advantages (+27.8% relative at for revisions), but easy problems are exactly where even a small amount of test-time compute (e.g., best-of-4 majority voting) would provide large gains for the larger model as well. The paper cannot distinguish whether the observed advantage comes from the smarter use of test-time compute or simply from having test-time compute at all.
What evidence exists in the paper. Figure 3 (left) shows majority voting reaching approximately 29% at 512 generations compared to greedy decoding at approximately 10–19% (the base model's pass@1 range mentioned in Section 4). This gap — roughly 10–19 percentage points from basic test-time compute alone — is available to the large model baseline but not provided. The FLOPs-matched results (Figure 9, Table in Section 7) show test-time compute advantages that are largest in regimes (easy problems, low ) where basic test-time strategies would likely help any model size. The paper does not include any ablation where the larger model receives a test-time compute budget.
Mitigation status. The paper acknowledges the non-optimal pretraining scaling as a caveat in Section 7 but does not address the zero-test-time-compute asymmetry at all. Both issues are deferred to future work.
The Revision Model Has a 38% Correct-to-Incorrect Reversion Rate and Revision Training Is Sensitive to Methodology
The revision model exhibits a serious practical flaw — it frequently "revises" correct answers into incorrect ones — and an attempt to further optimize it with on-policy RL caused performance to degrade, suggesting the approach is fragile in ways that are not fully understood.
The assumption or constraint. The revision model is trained exclusively on sequences where all in-context answers are incorrect and the target is a correct answer (Section 6.1). At test time, the model may produce a correct answer early in the revision chain and then encounter it in context during a subsequent revision step. Because the model was never trained on the pattern "see a correct answer, produce another correct answer (or recognize no revision is needed)," it has no learned behavior for this situation.
The consequence. The paper reports that "approximately 38% of correct answers get converted back to incorrect ones" (Section 6.1) in a naive approach. The mitigation — majority voting or verifier-based selection across the entire chain — is a patch, not a solution: it requires generating many revisions and then selecting the best one post-hoc, which wastes computation on reverting and then ignoring correct-to-incorrect revisions. In a latency-constrained setting where the agent cannot afford to generate long chains and then select, this 38% reversion rate would directly reduce final accuracy.
More concerning is the attempted optimization with ReST (Appendix K). When the revision model was further fine-tuned using on-policy data collection with RL-style training, performance with sequential revisions degraded substantially: at 256 generations, fully sequential performance dropped to approximately 33.5% compared to roughly 38.5% at the optimal sequential-parallel ratio. The paper hypothesizes that "on-policy data collection in ReST exacerbates spurious correlations in revision data." This negative result indicates that the revision training methodology is brittle — the positive results depend on specific choices (offline data construction, edit-distance-based pairing) that may not survive attempts at iterative improvement or transfer to other settings.
What evidence exists in the paper. The 38% reversion rate is reported in Section 6.1. Figure 6 (left) shows per-step pass@1 for the revision chain, confirming that accuracy does not monotonically increase (the chain includes steps where correctness drops). The ReST failure is documented in Appendix K, with Figure 16 showing monotonic performance degradation as the sequential-to-parallel ratio increases for the ReST model. The paper does not measure the reversion rate after FoldGRPO-style training with process rewards, so it is unknown whether process-reward-guided training of the folding mechanism would exacerbate or mitigate this problem.
Mitigation status. The paper mitigates the reversion problem at test time via majority voting or verifier-based chain selection but does not propose a training-time solution (e.g., including "no revision needed" examples in training data, training a halting criterion). The ReST degradation is presented as a negative result without analysis of root causes or proposed fixes. This limitation is partially acknowledged — the paper describes the mitigation approach — but the fragility of revision training to methodology changes is not discussed as a limitation.
Hard Problems Remain Essentially Unsolved — Test-Time Compute Cannot Create Capability
Despite the paper's positive results on easy-to-medium problems, the hardest problems show near-zero improvement from any test-time compute strategy, establishing a fundamental boundary on what the approach can achieve.
The assumption or constraint. The compute-optimal framework assumes that the base model has some non-zero probability of producing a correct solution — that there are correct answers "in the distribution" to be found or refined. This assumption fails for the hardest problems (difficulty bin 5), where the base model's pass@1 is near zero.
The consequence. Across all methods — search, revisions, and their compute-optimal combinations — bin 5 accuracy hovers at 1–3% regardless of compute budget. Figure 3 (right) shows both beam search and best-of-N at 1–3% at all budget levels for bin 5. Figure 7 (right) shows roughly 2–3% accuracy for bin 5 across all sequential-to-parallel ratios. In the FLOPs-matched comparison (Figure 9), the bin 5 scaling line is essentially flat near 0–5% for both revisions and search, and the larger model consistently outperforms test-time compute on these problems. The pretraining baseline for hard problems shows a −52.9% relative disadvantage for test-time compute at with PRM search, meaning the larger model is substantially better.
This is not a minor boundary case — it is a fundamental limitation that cleanly divides the problem space. For hard problems, no amount of additional test-time compute within the studied budgets (up to 512 generations) provides meaningful improvement. The paper is transparent about this, but the implication is significant: test-time compute amplifies existing capability but does not create it. If a problem requires knowledge, reasoning patterns, or capabilities that the base model does not possess, scaling inference compute is essentially useless. The approach offers no path forward for genuinely novel or out-of-distribution reasoning that exceeds the base model's training distribution.
What evidence exists in the paper. The failure on hard problems is consistently documented across all experiments: Figure 3 (right, bin 5), Figure 7 (right, bin 5), Figure 9 (bin 5 in both left and right panels), and the summary statistics in the FLOPs-matched bar charts (Figure 1, where "hard" shows negative relative improvements for test-time compute across all values). The paper's Section 7 takeaway box explicitly notes that pretraining is preferable for hard problems. The failure is well-characterized.
Mitigation status. The paper does not propose any solution for hard problems. The limitation is acknowledged transparently but treated as an inherent boundary rather than a problem to be solved. The implication — that some capabilities can only be acquired through pretraining, not recovered at inference time — is a finding rather than a bug, but it sharply bounds the applicability of the approach. For deployment scenarios where the problem distribution includes a non-trivial fraction of hard problems, the overall system performance will be upper-bounded by the base model's capability ceiling, regardless of how optimally test-time compute is allocated.
7. Implications and Future Directions
How This Work Changes the Landscape
This paper causes a category shift in how the field approaches context management for LLM agents. Before this work, the dominant paradigms treated context management as an engineering problem solved outside the agent's policy: summarization methods compressed history at arbitrary trigger points, and multi-agent systems decomposed tasks using handcrafted workflows. Both approaches treated the agent as a passive consumer of memory management decisions made by system designers. Context folding inverts this relationship, demonstrating that context management can be a learned cognitive skill optimized end-to-end through reinforcement learning — the agent actively decides when to decompose, what sub-task to assign, and what information to preserve, with all three decisions shaped by process rewards that target specific failure modes.
This is not merely an incremental improvement on existing context-management techniques. The paper's central diagnostic finding — that standard GRPO training on a context-folding agent actively degrades context management relative to an untrained agent (Table 2: Finish rate drops from 80.6% to 73.8% on BrowseComp-Plus, Main Len increases from 12,195 to 22,285 tokens, Scope accuracy drops from 77.4% to 76.2%) — reveals that the branching mechanism alone is insufficient. The agent with access to folding tools but trained only on outcome rewards learns worse behavior than one never trained at all. This is a genuinely surprising negative result that reframes the problem: context management is not a feature to be installed; it is a skill to be acquired, and the natural gradient from outcome rewards points in the wrong direction.
The paper's reconciliation of this failure through FoldGRPO — boosting the finish rate to 93.5%, compressing the main trajectory to 7,752 tokens while processing over 100K total, and achieving over 90% context compression — provides a template for how to teach agents structural skills that are only indirectly connected to final outcomes. The three process rewards (Unfolded Token Penalty, Out-of-Scope Penalty, Failure Penalty) operate as targeted interventions against specific failure modes rather than generic "good behavior" bonuses, establishing a design philosophy that extends beyond context management to any agent skill involving how work is structured rather than what answer is produced.
Resolving prior contradictions. The paper reconciles a tension in the agent-memory literature between the demonstrated benefits of context summarization (MemAgent, ReSum, Mem1) and the known fragility of long-context reasoning ("lost in the middle," documented by Liu et al., 2023). Prior work showed that summarization can help — but the paper shows why it helps inconsistently: summarization compresses at arbitrary boundaries, losing decision-relevant information when triggered mid-sub-task. Context folding compresses at sub-task completion boundaries, where intermediate details have served their purpose and only the conclusion matters for downstream decisions. The controlled comparison in Table 1 (Folding Agent + GRPO at 56.7% vs. Summary Agent + GRPO at 52.7% on BrowseComp-Plus, same model, same budget, same RL) isolates this boundary-alignment effect and demonstrates it is a measurable, practically significant factor — not just a philosophical preference.
Research directions that become more attractive. The paper makes process-reward design for structural agent behaviors a first-class research topic. The finding that outcome rewards alone are insufficient for teaching task decomposition — and that targeted penalties for structural violations work where outcome rewards fail — opens a broad design space. What other agent skills require process-level guidance? Task prioritization? Exploration-exploitation tradeoffs in tool use? Graceful recovery from dead ends? Each of these is a structural property of the trajectory that may not be learnable from sparse outcome signals alone. The paper's penalty-based approach (penalize structural violations rather than rewarding desired behavior) provides a concrete design pattern that can be adapted to other skills.
The paper also shifts attention from context window capacity to context organization quality. The results showing a 36B model with 32K active context matching or exceeding the same model with 327K raw context (Table 1: 62.0% vs. 54.0% on BrowseComp-Plus) — and approaching the performance of 100B+ models — suggest that investment in context management architectures may yield better returns than the ongoing arms race toward ever-larger context windows, at least for the class of long-horizon agent tasks studied.
Research directions that become less central. The paper's strong empirical result that blind summarization underperforms boundary-aligned folding (even with the same model, same budget, and same RL training) suggests that trigger-based summarization without task-structure awareness is a dead end for agent contexts. Future work on summarization for agents should incorporate sub-task boundary detection as a first-class consideration rather than treating compression timing as an independent engineering choice. Similarly, the finding that GRPO training degrades context management (Table 2) challenges the assumption that outcome-reward RL will naturally surface efficient behaviors — for structurally complex skills, explicit process guidance appears necessary, which diminishes enthusiasm for purely outcome-driven approaches to training long-horizon agents.
Follow-Up Research This Work Enables
Individual process reward ablation: which penalty matters most, and can we simplify? The paper demonstrates that the combination of three process rewards (Unfolded Token Penalty, Out-of-Scope Penalty, Failure Penalty) is effective, but provides no evidence about the contribution of each individual penalty. A minimal experiment would train three variants of FoldGRPO, each with exactly one of the three penalties ablated, under identical hyperparameters on BrowseComp-Plus. The key metrics would be not just pass@1 but the behavioral statistics in Table 2 (Finish, Main Len, Scope, # Branch) — the hypothesis being that the Unfolded Token Penalty drives Main Len reduction, the Out-of-Scope Penalty drives Scope accuracy, and the Failure Penalty drives overall tool-use efficiency. If one penalty accounts for most of the gain, the training framework could be simplified (particularly relevant for the Out-of-Scope Penalty, which requires an external GPT-5-nano judge). If all three are independently necessary, this would establish that the three failure modes (main-thread bloat, branch scope creep, failed tool calls) are genuinely distinct and cannot be addressed by a single process-reward signal.
Cross-model and cross-domain replication: does FoldGRPO's advantage over GRPO depend on the base model's pre-training? The paper tests a single model (Seed-OSS-36B-Instruct) on two benchmarks (BrowseComp-Plus, SWE-Bench Verified). The striking degradation under GRPO training (Table 2: GRPO makes context management worse) may be specific to this model's pre-training distribution or optimization landscape. A strong follow-up would replicate the FoldGRPO vs. GRPO comparison on at least two additional model families (e.g., Qwen-2.5-32B, Llama-3-70B) and one additional long-horizon domain (e.g., WebArena for web navigation, or a multi-hop QA dataset requiring extensive retrieval). The key question is whether GRPO consistently degrades context management across models and domains, or whether some base models naturally learn effective branching from outcome rewards alone. If the degradation is model-specific, this would identify pre-training properties (instruction-following? long-context attention quality?) that predict whether an agent can learn structural skills from sparse rewards — a finding with implications for base model selection in agent deployments.
Dynamic difficulty-adaptive branching: does the agent learn to modulate its branching behavior based on problem characteristics? The paper shows that RL training increases average branching and tool calls (Figure 4), and that this increase is larger on harder problem subsets. But the reported metrics are aggregate averages across difficulty levels — we cannot tell whether the agent adapts its strategy to individual problem difficulty or simply increases resource usage uniformly. A diagnostic experiment would correlate per-instance branching behavior with per-instance difficulty (using the paper's existing difficulty labels) and measure whether the correlation strengthens with FoldGRPO training. The hypothesis is that FoldGRPO's process rewards teach the agent to recognize when a problem needs decomposition: easy problems should trigger fewer branches and lighter tool use (Unfolded Token Penalty fires less often because the main thread stays compact naturally), while hard problems should trigger more branches and deeper exploration (the penalty creates pressure to offload into branches, but the outcome reward provides a countervailing pressure to explore thoroughly within branches). If the correlation between difficulty and branching behavior does not strengthen with training, this would suggest the agent is learning a fixed decomposition policy rather than an adaptive one — an important distinction for generalization to novel difficulty distributions.
Return message quality and its causal role in downstream decisions. The entire context-folding mechanism depends on the agent producing informative return messages. If summaries omit critical information, the main thread makes decisions based on incomplete evidence, and the folding architecture fails. The paper reports Scope accuracy (whether branch work was on-topic) but not summary quality (whether the return message contains all information needed for subsequent steps). A targeted experiment would: (1) manually annotate a subset of return messages for completeness (does the message capture all findings from the branch's tool calls?), and (2) measure whether FoldGRPO training improves summary quality relative to untrained and GRPO-trained folding agents. A stronger causal test would be to perturb return messages — randomly drop findings, inject errors — and measure downstream pass@1 degradation, establishing a sensitivity curve for information loss at folding boundaries. If return message quality is high and robust under FoldGRPO but fragile under GRPO, this would identify summary generation as a specific skill that the process rewards teach. If summary quality is poor even under FoldGRPO but the agent compensates through repeated branching, this would reveal a hidden inefficiency in the current approach and motivate explicit summary-quality process rewards.
Scaling FoldGRPO training steps: does the ReAct baseline catch up with more training? The paper trains both the folding agent and the 327K ReAct baseline for 50 steps (approximately 2 epochs). Given that ReAct trajectories are longer and the credit assignment problem is harder (no branching structure to isolate sub-problem credit), 50 steps may be insufficient for the ReAct baseline to converge. A simple but important follow-up would train the 327K ReAct agent for 200+ steps on BrowseComp-Plus and measure whether its performance approaches or exceeds the folding agent's. If ReAct performance saturates at ~55–57% regardless of training duration (while the folding agent reaches 62.0% in 50 steps), this would strongly support the paper's claim that the folding architecture provides a fundamental advantage, not just a training-efficiency one. If ReAct matches or exceeds the folding agent with sufficient training, this would reframe context folding as a training accelerator (reaching good performance faster) rather than a capability enhancer — still practically valuable, but conceptually distinct.
Folding with nested branches: does depth-2 decomposition help, and can process rewards scale to deeper hierarchies? The paper constrains the plan–execution scaffold to prevent nested branching (no branches within branches), explicitly to "maintain a clear structure and prevent nested complexity" (Section 2.2). But the case study in Figure 7 shows an agent creating branches for "Find publication with specific authors and topics," then "author count and Ph.D. status," then "Expand search for three-author publications" — a natural hierarchical decomposition where sub-tasks themselves decompose further. A follow-up would relax the no-nesting constraint and allow depth-2 branching (branches can create sub-branches), training with FoldGRPO on BrowseComp-Plus. The key measurement is whether depth-2 branching improves performance on the hardest problem instances (bin 5 and the compound-question experiments), where single-level decomposition may be insufficient. The process rewards would need to be extended: should the Unfolded Token Penalty apply recursively within branches? Should the Out-of-Scope Penalty be assessed relative to the immediate branch prompt or the root task? If depth-2 branching helps on hard problems but introduces training instability (due to the credit assignment problem becoming harder with deeper trees), this would identify a fundamental tension between decomposition depth and learnability — and motivate hierarchical credit assignment methods (e.g., reward propagation up the branch tree).
Practical Applications and Downstream Use Cases
Cost-efficient long-horizon agent deployment. Organizations running deep-research or agentic-coding agents at scale face a direct tension between context length and inference cost: the quadratic scaling of attention means that doubling context length roughly quadruples per-token cost, and long contexts increase KV-cache memory pressure, reducing throughput. The paper's result — a 36B model with 32K active context matching a 327K-context baseline while making more tool calls (19.2 vs. 10.2 on BrowseComp-Plus, 96.5 vs. 55.4 on SWE-Bench; Table 1) — translates directly to a cost reduction for batch inference pipelines. A deployment processing 10,000 queries/day could run the folding agent with 32K active context and sequential branch execution, trading the latency cost of serial branch execution for the per-token cost reduction of short-context generation. The 1.43× training step speedup and 1.52× rollout speedup (Figure 8) further reduce the cost of model fine-tuning and iteration. The primary tradeoff is latency: sequential branch execution means the agent cannot parallelize sub-tasks, and total wall-clock time may be higher even if total FLOPs are similar. This makes the approach best suited for throughput-oriented batch processing (periodic report generation, overnight code review, training data synthesis) rather than latency-sensitive interactive applications.
Self-improvement data generation pipelines. The paper explicitly envisions "distilling the outputs of applying additional test-time compute back into the base LLM, enabling an iterative self-improvement loop" (Section 8, paraphrased from the broader context-folding vision). The folding agent's ability to generate high-quality trajectories at 10× context compression makes it an attractive data-generation engine for self-improvement. In a STaR/ReST-style pipeline, the folding agent generates solutions on training data using its learned decomposition strategy; correct trajectories are distilled back into the base model through fine-tuning. The key advantage is that folded trajectories are more digestible for the student model: the main thread contains high-level reasoning and sub-task outcomes, while branch internals can be optionally included or excluded from training data depending on whether execution details or planning decisions are the learning target. The paper's negative result with ReST on the revision model (Appendix K) — where on-policy data collection caused performance degradation — serves as a cautionary tale: self-improvement with folding may require careful data filtering or off-policy data construction to avoid amplifying spurious correlations. A practical pipeline would generate folded trajectories, score them with the verifier, retain only correct trajectories, and fine-tune the base model on the main-thread planning decisions (branch prompts and their outcomes) while optionally discarding branch internals to keep training sequences compact.
On-device or edge deployment with constrained context windows. For deployment scenarios where hardware constraints limit context length (edge devices, mobile inference, browser-based models with WebGPU), the paper's finding that a 32K active context can substitute for 327K raw context is directly actionable. A folding-capable agent could be deployed on a device with a 32K token context limit, handling tasks that would otherwise require cloud offloading to a larger-context model. The difficulty estimator (Section 4.2, Figure 3) could serve double duty: routing easy problems to the on-device folding agent and escalating genuinely hard problems (bin 5) to a cloud-based large-context model. The key implementation challenge is the branch execution mechanism: on-device, branches would run sequentially on the same model instance, sharing the KV-cache prefix for efficiency. The 10-branch limit in the paper's experiments provides a natural budget for on-device processing — the agent can create up to 10 sub-task contexts before the total token budget is exhausted — and the 93.5% finish rate under FoldGRPO (Table 2) means the agent reliably completes tasks within that budget rather than hitting the context limit and failing.
Agent development platforms and framework design. The paper's plan–execution scaffold and FoldGRPO training framework provide a concrete reference architecture for agent development platforms (OpenHands, LangGraph, AutoGen, CrewAI) that want to offer context-folding as a built-in capability. Rather than requiring users to handcraft multi-agent decomposition workflows or configure summarization triggers, a platform could provide branch and return as standard tools, implement the KV-cache rollback mechanism for efficient folding, and offer FoldGRPO as a training option for users who want to fine-tune agents on domain-specific tasks. The paper's finding that the folding agent generalizes to 50 combined questions using 32.6 branches despite being trained on tasks requiring at most 10 (Figure 5, right) suggests that a pre-trained folding agent could be deployed zero-shot on new task distributions with minimal adaptation — the decomposition skill transfers, even if the specific domain tools differ. The primary integration challenge is the asynchronous rollout infrastructure (Appendix A.2) needed for efficient training, which platform providers would need to support.
When to Prefer This Method
The paper articulates a clear tradeoff between context folding, raw-context scaling, and summarization-based compression, grounded in the experimental results. The decision framework follows naturally from the paper's empirical findings:
Prefer context folding with FoldGRPO over raw-context ReAct when:
- The task involves extensive tool use that generates high-volume observations (web search results, codebase exploration, test outputs) where most intermediate details are not needed for high-level reasoning. Table 1 shows the folding agent making 19.2 tool calls on BrowseComp-Plus vs. 10.2 for ReAct — the agent does more exploration, not less, but isolates the resulting context growth in branches. For tasks where tool outputs are compact and every detail matters for every subsequent decision, raw-context accumulation may be sufficient and simpler.
- The base model's performance degrades with context length — i.e., the "lost in the middle" problem is empirically present. The paper demonstrates this degradation implicitly: the 32K ReAct baseline achieves only 28.6% on BrowseComp-Plus vs. 47.8% for 327K ReAct, and even the 327K ReAct agent benefits from the folding mechanism's structure despite having access to the same total token budget. If the model handles long contexts well (e.g., Gemini 2.5 with claimed strong long-context attention), the relative advantage of folding may be smaller.
- Training budget exists for process-reward-based RL. The untrained folding agent underperforms the untrained long-context ReAct baseline (42.0% vs. 47.8% on BrowseComp-Plus; Table 1). The mechanism only pays off after FoldGRPO training. For zero-shot deployment without fine-tuning, raw-context ReAct remains the safer default.
Prefer context folding over summarization-based compression when:
- Task structure has natural sub-task boundaries that the agent can learn to recognize. The plan–execution framework works because deep research and software engineering naturally decompose into "explore candidate → verify conditions → expand search → confirm details" sub-tasks (Figure 7 case study). For tasks without clear decomposition boundaries — continuous dialogue, open-ended creative writing, streaming data analysis — the folding boundaries may be arbitrary, and summarization at capacity limits may be equally effective.
- Training data is available for the target domain. The folding mechanism requires RL training to learn effective decomposition; summarization can work zero-shot with generic summarization prompts. If in-domain training is infeasible, summarization may be the pragmatic choice even if folding would outperform given sufficient training.
Prefer raw-context scaling (larger context window or larger model) over context folding when:
- The problem distribution includes a substantial fraction of genuinely hard instances where the base model's capability is the bottleneck, not context management. The paper shows that hard problems (bin 5) see near-zero improvement from folding (Figure 3, Figure 7 right) and that the 14× larger model consistently outperforms test-time strategies on these instances (Figure 9). If the target workload includes tasks outside the base model's capability range, pretraining investment dominates.
- Latency is the binding constraint and parallel execution is feasible. The sequential plan–execution design blocks the main thread during branch execution. Raw-context ReAct can generate actions in a single forward pass through the accumulated context. For real-time interactive agents where 2× wall-clock time is unacceptable even if total FLOPs are comparable, raw-context ReAct may be preferable. The paper's parallel branching experiment (Section 4.5.3) showed no accuracy gain from parallel execution on BrowseComp-Plus, suggesting the task structure favors depth-first sequential exploration — but for inherently parallelizable tasks (e.g., WideSearch), a raw-context baseline with parallel tool calls might have a latency advantage.
The paper does not claim that context folding is universally superior. The difficulty-stratified results (Figure 3), the hard-problem failure boundary (Section 4.2), and the careful framing of the mechanism as "a principled path" rather than a solved problem (Section 6) all indicate the authors understand these tradeoffs. The decision rules above are grounded in the paper's own evidence about where folding helps (medium-difficulty, decomposable tasks with training budget) and where it does not (hard problems beyond base capability, latency-constrained settings, domains without training data).