3963 words
20 minutes
Two Hierarchies: Memory, Planning, and the Detail You Are Allowed to Lose

A long-horizon agent produces more history than it can hold. That is the entire problem, and every serious 2026 answer to it does the same thing at some level: put structure somewhere. Structure over the past, so a long session’s record stays navigable. Structure over the live window, so the working context stays small enough to reason in. Put those two on one slide and they look like a matched pair, and that is how most write-ups have filed them.

They are not a matched pair. HORMA, from Duke University and Snowflake AI Research, cites Context-Folding, from ByteDance Seed with Carnegie Mellon and Stanford, three separate times in its own bibliography [1], [2]. Every one of those citations describes prior work HORMA is arguing past. The disagreement is not about which half of the timeline each system covers. It is about whether the detail you compress away is allowed to be gone.

Figure 1 - Diagram contrasting a memory hierarchy whose summaries keep links back to raw trajectories against a planning hierarchy that deletes a completed branch and rolls the cache back

Figure 1 - Two hierarchies, one axis: Both systems build a hierarchy and both shrink the context an agent reasons over. One keeps every summary tied to the raw record it came from. The other removes the branch and rolls the cache back to the branch point, leaving only the summary. That is the choice, and it is not a scope difference.


The citation that reframes the pairing#

HORMA’s opening paragraph groups context folding with summarization and calls both out by name [1]:

“Existing approaches suffer from two key limitations: agents either act as history hoarders, retaining large amounts of history, leading to context overload, information dilution, prohibitive latency and high inference cost, or rely on lossy compression mechanisms, including summarization and context folding, which irreversibly discard fine-grained information necessary for downstream reasoning.”

The second citation puts Context-Folding among memory systems that “treat memory construction and retrieval as a monolithic system that is jointly optimized within a unified framework,” which is precisely the design HORMA decouples [1]. The third files it in related work as “hierarchical folding” [1]. Three appearances, three critiques.

Two things need saying before we go further.

The charge is accurate to the mechanism. This is not a strawman that a careful reading of the second paper dissolves. Context-Folding really does delete, and it says so plainly.

There is no head-to-head result. HORMA never benchmarks against the trained Context-Folding agent. The “Fold” baseline in HORMA’s ALFWorld table is HORMA’s own simple folding heuristic implemented inside ReAct, and the citation attached to it is to ReAct [1]. Nobody has run these two systems against each other. The disagreement is architectural and citational, and it is unresolved. Anyone telling you one of these papers beat the other is reading a summary, not the papers.

Figure 2 - Diagram showing one paper citing another three times, with each citation labeled by the critique it carries, and a banner noting no head-to-head benchmark exists

Figure 2 - Cited, not partnered: The relationship between these two papers is one-directional and adversarial. It is also untested. A citational disagreement is real evidence about how two research teams frame the problem, and it is not evidence about which system wins on your workload.


Context-Folding: delete the branch, roll back the cache#

Context-Folding gives the agent exactly two special actions [2]. branch creates “a temporary sub-trajectory for a localized subtask” [2]. return will “summarize the outcome and rejoin the main thread, after which the intermediate steps within the branch are ‘folded’, removed from the context, leaving only a concise summary from the return call” [2].

The implementation detail is what makes the deletion literal. On return, the agent “rolls back the KV-cache to the corresponding branch position” [2]. Folding is a genuine cache rollback rather than a re-prefill, which is where the efficiency comes from, and it is also why nothing survives except the summary.

The framework runs as a plan-execution loop with two states [2], [3]. Planning State holds the main thread, does decomposition, and discourages token-intensive tool use. Execution State is life inside a branch, where “creating new branches is disabled,” so branches never nest [2].

Figure 3 - Diagram of a main planning thread opening a branch for a sub-task, then folding it away on return with the key-value cache rolled back to the branch point

Figure 3 - Branch, work, return, roll back: Nesting is disabled by design, which keeps the structure flat. The rollback is what makes the saving real, and it is also what makes the loss permanent.

The training is the load-bearing part#

Outcome-only reward did not work. The paper names the two failure modes it produced: the agent “leaving token-intensive operations unfolded in the main context,” and the agent “failing to return from a sub-branch after a sub-task is completed” [2]. FoldGRPO adds a token-level process reward to standard GRPO, with exactly three penalties [2]:

  • Unfolded token penalty (-1), applied to main-thread tokens once the main thread’s context exceeds 50% of the working-context limit, excluding turns that create a branch.
  • Out-scope penalty (-0.2), applied to every token in a branch that GPT-5-nano judges to have acted outside its assigned sub-task.
  • Failure penalty (-1), applied to every token in a failed tool-call turn.

Worth noting for anyone thinking about reproducibility: the out-scope penalty puts an external vendor model inside the training loop as a judge [2].

Figure 4 - Diagram showing three process-reward penalties applied to different token spans in a folding agent's trajectory

Figure 4 - Three penalties, three failure modes: Each process reward exists because the outcome-only version of this agent misbehaved in a specific way. The unfolded-token penalty punishes hoarding in the main thread, the out-scope penalty punishes a branch that wanders off its sub-task, and the failure penalty punishes broken tool calls.

What the numbers actually say#

The evaluation runs on BrowseComp-Plus (150 instances) and SWE-Bench Verified (500 instances), on a Seed-OSS-36B-Instruct base model, with baselines given the same base model, data, infrastructure, and RL hyperparameters [2]. ALFWorld, which is often attached to this paper secondhand, belongs to the other one.

The folding agent trained with FoldGRPO reaches pass@1 of 0.620 on BrowseComp-Plus and 0.580 on SWE-Bench Verified [2]. It beats the matched ReAct long-context baseline (0.478 and 0.552), the RL-trained summarization baseline (0.527 and 0.550), and plain GRPO on the same folding agent (0.567 and 0.564) [2]. It does not beat GPT-5 (0.793 and 0.718), and the paper does not claim it does [2]. Its own calibrated wording is “performance comparable to agents built on much larger 100B+ parameter models,” and it is genuinely comparable to DeepSeek-V3.1 (0.613 and 0.610) [2].

The result we find most useful is the one that looks like a failure. Without RL, the folding agent scores 0.420 and 0.492, which is below its own ReAct baseline [2]. Folding as a mechanism does not pay for itself. Folding plus the training that teaches an agent when to fold does.

Figure 5 - Bar chart comparing pass@1 scores for a folding agent with and without reinforcement learning against a matched long-context baseline and a much larger model

Figure 5 - The architecture only pays after training: Untrained, the folding agent scores 0.420 on BrowseComp-Plus against the matched baseline’s 0.478 [2]. Trained with FoldGRPO it reaches 0.620. GPT-5’s 0.793 stays out of reach, which the paper states plainly rather than burying.

One number gets misquoted constantly, so here it is with the qualifier attached. The folding agent holds 32,768 tokens active at any moment against the long-context ReAct baseline’s 327,680-token window [2]. That is a tenth of the context in the window at once. The folding agent’s total budget is 32,768 tokens per branch across up to 10 branches, which is 327,680 tokens in total, deliberately matched to the baseline so the comparison isolates active window size [2]. Total token cost is comparable. A tenth of the tokens is not what happened.

KEY INSIGHT: A context-management mechanism is not a feature you switch on. Untrained, this one scored below the baseline it was meant to improve. Budget for the training loop or budget for a regression.


HORMA: organize first, then navigate#

HORMA splits memory into two decoupled stages that share one hierarchical file-system workspace, both operating through executable Bash commands [1].

The construction stage builds the hierarchy at write time from a domain-agnostic prompt specifying three organizational principles: entity tracking, event abstraction, and relation grouping [1]. Summaries and structured entities sit at the higher levels. The property that matters for this article is what sits underneath them: every summary stays linked to the raw trajectory it came from, so the agent can drop back to ground truth rather than trusting a summary that may have drifted [1].

The retrieval stage is a trained navigator rather than a cosine lookup. It moves through the workspace using ls, grep, cd, and cat, augmented with exactly two terminal actions, select and done [1]. Training is GRPO against an evidence-grounded retrieval reward based on overlap between retrieved context and ground-truth evidence taken from the LoCoMo dataset, deliberately decoupled from downstream task reward [1].

Figure 6 - Diagram of a two-stage memory architecture where a construction stage builds a hierarchy of summaries linked back to raw trajectories, and a trained navigator traverses it

Figure 6 - Organize at write time, navigate at read time: The construction stage pays the organization cost once, so retrieval becomes traversal instead of similarity scoring. The links running from each summary down to its raw trajectory are the design decision the rest of this article turns on.

One correction to the secondhand version of this paper. HORMA’s headline configuration uses Claude Sonnet 4.5 as the backbone for reasoning, memory management, and retrieval across every compared method, so the comparison isolates the architecture rather than the model [1]. Qwen 3.5 4B appears in the ablations, where the backbone for the management role and the retrieval role is varied independently, not as “HORMA’s retriever” [1]. The accurate version of that story is better anyway: the GRPO-trained 4B navigator reaches 58.0 on LongMemEval, beating the Claude Sonnet 4.5 configuration’s 55.9, despite having trained only on LoCoMo conversation data [1].

On efficiency, the safe sentence is the one the paper’s introduction gives. HORMA uses as little as 3.07% and at most 22.17% of the tokens the baselines needed on LoCoMo, and between 1.24% and 16.19% on LongMemEval [1]. The 22.17% figure is the top of a range measured against a set of named baselines, and ALFWorld is not covered by it at all.

Figure 7 - Chart showing a hierarchical memory agent's token consumption as a small fraction of baseline consumption across two conversational benchmarks, with ranges labeled

Figure 7 - A range, not a headline: The often-quoted 22.17% is the worst case on one benchmark, meaning that even against the baseline it saves least on, the hierarchy still used roughly a fifth of that baseline’s tokens [1]. On LongMemEval the range is 1.24% to 16.19%.


The axis is recoverability, not past versus future#

Here is the whole argument in two sentences. Context-Folding bets that irreversible discard is acceptable as long as you discard at a sub-task boundary rather than at an arbitrary token threshold, which is exactly how it positions itself against summarization: reasoning is “only compacted once its utility is realized” [2]. HORMA bets that irreversibility is the defect, and that the compressed form should be a pointer rather than a replacement [1].

Both bets are defensible. They are also mutually exclusive on any given piece of context. You either kept the raw trajectory or you rolled the cache back over it.

Figure 8 - Diagram of a single fork where one path compresses a completed sub-task into a summary that retains a link to its raw record, and the other replaces the record entirely

Figure 8 - Pointer or replacement: The same compression step ends in two different states, one leaving a way back to the original record and one leaving a summary that is now the only account of what happened. Nothing about the timeline distinguishes these two designs, and everything about the recovery path does.

The most honest empirical crumb on HORMA’s side comes from its own ALFWorld table, and it needs its scope stated. The naive Fold baseline “underperforms sliding window despite preserving reasoning traces, likely because retained reasoning significantly increases context cost and reduces actionable capacity” [1]. That is evidence about a simple folding heuristic inside ReAct. It is not evidence about FoldGRPO, which was never run.

KEY INSIGHT: When two architectures look like complements on a slide, check whether one cites the other. A citation is a claim about compatibility that the authors were willing to publish.


Two results that invert the intuition#

HORMA runs a study that varies the backbone for the management role and the retrieval role independently, and the conclusion is the sharpest thing in either paper [1]:

“This demonstrates that flawed memory organization cannot be compensated for by high-quality retrieval. If the manager fails to induce a coherent structure, even an optimal navigation policy is restricted by the deficiencies of the underlying workspace.”

Concretely, a Qwen 3.5 4B memory manager lags badly, and swapping in Claude Sonnet 4.5 as its retriever produces only marginal improvement [1]. Most teams building agent memory spend their model budget on the retrieval side, because retrieval is where the visible failures happen. This result says the visible failures are downstream of an invisible one.

Figure 9 - Diagram contrasting a weak memory manager feeding a strong retriever against a strong manager feeding a modest retriever, with the outcome quality shown for each

Figure 9 - The money goes on the manager: A high-capacity retriever cannot repair a workspace that was organized badly in the first place. The organization step happens once, it happens out of sight, and it caps everything downstream of it.

The second inversion is quieter and more useful. On LongMemEval, the unconstrained “No limit” setting scores 20.4, losing to nearly every context-constrained method in the table, including HORMA’s 55.9 and A-MEM’s 51.8 [1]. The paper’s own explanation is that “several baselines even outperform no-limit counterparts due to implicit filtering of irrelevant context” [1]. Giving the agent everything made it worse than giving it a filtered slice.

Figure 10 - Bar chart showing an unconstrained full-context configuration scoring far below several context-constrained memory methods on a long-memory benchmark

Figure 10 - Full context is not the ceiling: On LongMemEval the unconstrained baseline scores 20.4 while the hierarchical navigator scores 55.9 [1]. Handing a long-horizon agent its complete history is not a safe default, and it is not the upper bound that context-management work is trying to approach.

That result rewrites what context management is for. The usual framing treats a bigger window as the ideal and every compression scheme as a compromise on the way there. If more context can score a third of what less context scores, filtering is doing work a larger window does not do for free.

KEY INSIGHT: Stop treating full context as the target that compression approximates. On the wrong workload, unfiltered history is the worst configuration on the table.


What the shipping teams did instead#

Neither paper’s design is what production teams described in 2026, and the gap is instructive.

Lance Martin of Anthropic frames Claude’s memory system on human memory’s two subsystems [4]:

“The human brain has two kind of interesting systems for memory. So, one is as you go about your day, the hippocampus is kind of writing traces of kind of short-term, very fast kind of experiential memory… When you go to bed at night, though, an offline process or out-of-band process, dreams.”

Dreaming, in his framing, “stores certain important details to long-term memory in the cortex” [4].

In-band writing is the agent writing to a memory directory while a task runs. The out-of-band pass, which Anthropic calls dreaming and which we covered as a gated research preview in Memory and Dreaming, reviews the accumulated store afterwards and corrects what the in-band writer got wrong [4], [6]. Martin’s reason for the split is that in-band memory is locally correct and globally unreliable: the agent writes what helps it finish the current task, not what will help a future one [4].

His illustration is a Claude Plays Pokemon run where an incorrect memory about a location caused repeated mislocalization: “Five out of five replicates with raw memory store fell down this trap” [4]. With dreaming, the error is corrected “consistently” [4]. Treat that for exactly what it is, a self-reported, unaudited demonstration on one game, run and narrated by the speaker. It illustrates a mechanism, and it measures nothing.

Independently, monday.com engineering managers Omri Bruchim and Tomer Ast described the data model behind their assistant as “a slow engine that runs on a long time window and learns the user and their work and a fast engine that reads what’s happening right now and how it affects the user’s work. One knows you and the other one knows your day” [5]. The slow engine mines weeks of activity into a durable profile that gets reinforced as patterns hold. The fast engine recomputes live signals over a short recent window [5].

Then they name the provenance themselves [5]:

“This split isn’t something we invented. It’s present in two totally different fields. In neuroscience, this split is referred to as complementary learning systems.”

In data-processing architecture, they add, the same split “is referred to as a lambda architecture” [5].

Figure 11 - Diagram of two independent teams arriving at the same fast-write and slow-consolidate memory shape from two unrelated analogies

Figure 11 - Two routes, one shape: An agent-runtime team reached a two-timescale memory split through a dreaming analogy. A data-platform team reached the same split through complementary learning systems and lambda architecture. Neither talk mentions the other, and neither mentions either paper in this article.

The convergence is the finding, and the connection to the two papers is our own synthesis rather than anything either speaker claims. Both talks are first-party accounts with no independent audit, and we are the ones placing them next to HORMA and Context-Folding. What the placement shows is that both production teams solved an upstream problem the papers do not address: not how memory is laid out, but how often it is written and corrected. Martin’s substrate position, “Let the model structure and maintain its own memory. Don’t give it a prescribed memory schema,” lands closer to HORMA’s emergent hierarchy than to any fixed schema, and he arrived at it without reference to the paper [4].

Research is also trying the opposite of all of this, which is worth two paragraphs as a stress test rather than a section. Metis puts short-term memory inside the transformer: a fixed-size memory matrix in each Metis-enabled layer, written during the ordinary forward pass by a frozen learned policy, and read back through a second attention branch that is mixed into the standard self-attention output [7], [8]. There is no external store, no retrieval call, and no gradient update at inference. It is built on frozen Qwen3.5 backbones at 4B, 9B, and 27B [7].

Its own reported ablations are the reason it belongs here. The memory branch is summed into the same attention computation that does the reasoning, so an overflowing memory matrix degrades recall and ordinary reasoning together rather than politely returning nothing [7]. Full context still wins by a wide margin: Metis-27B scores 26.74 on LoCoMo (Gold) and 50.82 on NextMem under the no-context setting, against full-context Qwen3.5-27B at 65.03 and 78.80 [7]. The efficiency case is real, since the full-context key-value cache reaches 1,066.96 MB at 32K while the Metis state stays constant [7]. State the trade honestly, though: external memory that is stale can be ignored, and memory fused into the reasoning pathway cannot.


What a practitioner does with this#

Four things follow from the above, none of which require adopting either paper.

Spend on the memory manager, not the retriever. The cross-backbone result is the most actionable finding in either paper, and it points at the least glamorous component [1]. If you are running a two-model split for cost reasons, put the capable model on the write side.

Do not assume more context is safer. A no-limit configuration losing to filtered ones by 35.5 points is a reason to actually measure the unfiltered baseline on your own workload before treating it as the reference [1]. It may be the thing you are trying to beat, and it may be the floor.

Pick your bet against your recovery requirements. Irreversible folding fits workloads where the sub-task boundary is crisp, the summary is genuinely sufficient, and nobody will later ask why a decision was made: a search sweep, a build-and-test cycle, a bounded refactor. Recoverable hierarchy fits workloads where somebody audits the trail: incident review, regulated decisions, anything where “the summary said so” is not an acceptable answer. We have made the same argument from the retrieval side in From Agentic RAG to Compiled Knowledge and built the storage half of it in Build Your Own Compiled Knowledge Engine in Postgres [9], [10].

Make the record durable before you make it clever. Both production teams started with a write-side discipline rather than a retrieval architecture. A hierarchy over a record that can be lost mid-task is a hierarchy over nothing.

Figure 12 - Decision diagram routing workloads to either an irreversible folding strategy or a recoverable hierarchy strategy based on whether the trail will be audited

Figure 12 - Which bet fits which workload: The question that separates the two designs is not how long the task runs. It is whether anybody will need to reconstruct why a step happened after the summary is all that remains.


Conclusion#

The tidy version of this story is that long-horizon agents need two hierarchies, one for the past and one for the future, and that the two papers here supply one each. That version is a listicle, and the papers do not support it. What they support is a genuine disagreement between two research teams about whether compressed detail should remain recoverable, published in one direction, three times, with no benchmark ever run between them.

Take the disagreement seriously and the engineering question changes shape. Instead of “which context-management technique is best,” it becomes “what does this workload need to be able to reconstruct.” That question has a different answer for a search sweep than for a regulated approval chain. Neither answer is a default.

The rest of the evidence points the same way. Untrained folding scored below the baseline it was meant to improve. A weak memory manager could not be rescued by a strong retriever. An unconstrained context window scored 20.4 where a filtered one scored 55.9 [1]. Two production teams, working on unrelated problems, both started with write-side cadence rather than retrieval structure. None of that is an argument for a particular architecture, and all of it is an argument against picking one because it looked complementary on a diagram.


References#

[1] H.-L. Hsu, N. L. Kuang, B. Liu, Z. Yao, and Y. He, “Organize then Retrieve: Hierarchical Memory Navigation for Efficient Agents,” arXiv:2606.11680, Jun 2026. https://arxiv.org/abs/2606.11680

[2] W. Sun, M. Lu, Z. Ling, K. Liu, X. Yao, Y. Yang, and J. Chen, “Scaling Long-Horizon LLM Agent via Context-Folding,” arXiv:2510.11967, Oct 2025. https://arxiv.org/abs/2510.11967

[3] W. Sun et al., “Context-Folding,” project page, 2025. https://context-folding.github.io/

[4] L. Martin, “Claude for Long-Horizon Tasks,” Anthropic, AI Engineer, 2026. https://www.youtube.com/watch?v=9QebvrrY3KY

[5] O. Bruchim and T. Ast, “From Systems of Record to Systems of Context,” monday.com, AI Engineer, 2026. https://www.youtube.com/watch?v=Btk8wDUVs74

[6] G. Dotzlaw, K. Dotzlaw, and R. Dotzlaw, “Memory and Dreaming: How Anthropic Just Shipped the Karpathy Wiki Pattern,” 2026. /insights/ai-08-memory-and-dreaming/

[7] Z. Zhang, Z. Guo, Y. Sun, X. Zhang, X. Hao, Z. Lin, Y. Zhang, X. Zhao, T. Shen, B. Tang, Z.-Q. J. Xu, J. Yan, H. Wang, X. Chen, F. Xiong, Z. Li, and T.-S. Chua, “Metis: Memory Foundation Model,” arXiv:2607.26760, Jul 2026. https://arxiv.org/abs/2607.26760

[8] MemTensor, “Metis,” GitHub repository, 2026. https://github.com/MemTensor/Metis

[9] G. Dotzlaw, K. Dotzlaw, and R. Dotzlaw, “From Agentic RAG to Compiled Knowledge: Why Karpathy’s Wiki Idea Is Spreading,” 2026. /insights/ai-02-agentic-rag-to-compiled-knowledge/

[10] G. Dotzlaw, K. Dotzlaw, and R. Dotzlaw, “Build Your Own Compiled Knowledge Engine in Postgres,” 2026. /insights/ai-06-build-your-own-compiled-knowledge-engine-in-postgres/

Two Hierarchies: Memory, Planning, and the Detail You Are Allowed to Lose
https://dotzlaw.com/insights/ai-17-two-hierarchies-memory-planning/
Author
Gary Dotzlaw, Katrina Dotzlaw, Ryan Dotzlaw
Published at
2026-08-13
License
CC BY-NC-SA 4.0

Building production AI, or modernizing a legacy system?

That is the kind of work we do at Dotzlaw Consulting. Book a free 20-minute intro call and tell us what you are trying to build, or what is slowing you down.

← Back to Insights