Folio: Recoverable Multi-Resolution Context Folding for Long-Horizon Language Agents: what it means for business leaders

Folio replaces model-written summaries of a long agent history with a deterministic fold over views recorded during execution, solving 66 of 75 LOCA-bench tasks against 54 for the same runtime with summarization, at 2.4 times lower cost.

1. What the method is

Folio is a context manager for language agents that run long enough to outgrow their context window. Instead of asking a model to summarize old history when the window fills, it records the history at three linked levels while the agent works: a few-line turn note the model writes as part of its ordinary reply, a manifest row the runtime writes for every tool call and reply, and the full captured source records. Every call has one handle, such as t3.12, that stays valid at every level and after every fold. Folding then becomes a selection among views that already exist, done by the runtime with no model call. Three tools let the agent reach folded evidence through the same handles, and a cost rule decides when to fold by pricing the size of the context the fold will land at.

2. Why the method was developed

Agents append every tool result and reply to a history that is reread on each request at the provider's input price, and on hard tasks it exceeds the window before the work is done. The usual remedy is model-written compaction: a separate request reads the history and writes a summary. That costs a slow, billed request each time, the work grows with the number of compactions, and the link from the summary back to its source is only whatever the summarizer happened to record. Earlier cost models for prompt-cached sessions decide when to compact but treat the size after compaction as given, either a restart to the bare system prompt or whatever the summarizer returns. Folding keeps part of the history, so how much is kept is a decision with its own cost, and the authors argue the trigger should price it.

3. Who should care

Engineering teams that build or operate agent harnesses are the direct audience: this is a design for the context layer, not a model, and it could be adopted in a runtime we control. Finance and whoever owns our inference bill should care because the saving comes from carrying less history per request while keeping the provider's prompt cache intact, which is where long agent sessions spend most of their money. Product owners of long-running workflows, such as data analysis, reconciliation or scheduling over many tool calls, should care because the gains appear late in a session, when earlier work has been compacted several times. Security and platform teams need to look at one component: a recovery tool that runs shell or Python commands the model writes over stored outputs, whose isolation the paper does not evaluate. Buyers of closed agent products cannot adopt it themselves.

4. How the method works

The runtime sits between agent and tools. It appends each event to a log, writes a manifest row per call with tool, purpose, status, size, first line and a one-line shape of large results, and stores the model's turn note at turn close. When a fold fires, a planner renders older turns at coarser levels within a layout budget, here 60K tokens, keeps the open turn's earliest small results and newest results verbatim, and never redraws an already sent line more richly, so the unchanged outline stays a byte-identical cached prefix. The outline prints handles. The agent passes them to scan for bounded page reads and search, to ctx to run a command over the full text in a file and return only the answer, and to a dossier that keeps findings with their source across folds. The trigger folds once the cached tokens carried above the landing point have cost as much as rebuilding it.

5. How it was evaluated

The authors used LOCA-bench, an open benchmark of tool-using tasks whose context grows with the environment: 15 environments, five seeds each, 75 tasks with deterministic graders. They ran the tasks as five sessions of 15 consecutive tasks, so later tasks sit on top of earlier history. Every system used the same model, DeepSeek-V4-Pro. Folio ran in the Piki runtime with a 1M-token window and again with 128K. Baselines were the same runtime with model-written compaction at 90% of the window, plus Claude Code, Codex and SoL-Pi with 1M windows. Metrics were graded successes, working time per task, and, for the two Piki configurations only, token usage normalized to cached-read prices; the closed systems expose no usage, so their cost was not compared. Each session ran once per system. Component ablations and a sweep of the landing budget mostly covered a single 15-task session.

6. How it performed

Folio solved 66 of 75 tasks, against 54 for the same runtime with summarization, 59 for Claude Code, 57 for Codex and 49 for SoL-Pi, at a mean 10.2 minutes per task against 16.3 to 21.0. The differences from the same runtime and SoL-Pi are statistically significant; those from Claude Code and Codex are not. Normalized cost was 2.4 times lower than the same runtime, a median fold took 0.6 seconds against 101 seconds for a model-written compaction, and removing the outline raised cost by 63%. With a 128K window it still solved 60. The limits are real: one benchmark, one model and price structure, one run per session with swings of three to four tasks in 15, model-written notes that can be wrong, and an unevaluated execution tool. Our call is to pilot: the design is worth testing in any agent runtime we own, with our own models, prices and sandboxing. (Source: arXiv 2611.16627, 2026)

← Back to dossier index