# Prior art: who else folds an agent's context, and how Gnosh differs Gnosh works a task as a call stack. The agent enters a todo, works on it, and leaves it with a result. Everything it read and ran inside the todo then leaves the model's context, and the result stays, the way a function's locals go when it returns and only its value comes back. We call this functional AI (https://gnosh.ai/functional-ai.html). Others have built parts of this. This page says who, and how Gnosh differs. Checked 4 November 2026; NVIDIA's paper, Valentin Sasek's frame stack and Playbooks AI added 6 November. ## In plain words The closest earlier work is Context-Folding, by ByteDance Seed, Carnegie Mellon and Stanford (October 2025). Its agent can open a branch for a sub-task. When the branch is done, the agent returns one message about it, the branch's steps leave the context, and only that message stays. Gnosh's frames also close finished work out of the context. They differ in five ways: 1. **What is kept, and where.** Context-Folding keeps one message, in the context. Gnosh keeps the result in the context and also in mem, a Gno program on your disk, beside the plan and the thoughts the agent noted while it worked. The agent can look any of it up later. 2. **Depth.** In Context-Folding a branch cannot open another branch. Gnosh's frames nest as deep as the plan does: a todo inside a todo inside a todo. 3. **Beyond one session.** A Context-Folding run begins and ends with its task. Gnosh's plan outlives the session: the next session starts where the last one stopped, and several sessions can work one plan at once. 4. **No training.** Context-Folding teaches its model to fold with reinforcement learning. Gnosh's model is told how in its prompt, and calls mem from Gno like any other code. 5. **When the context fills anyway.** If one todo's work outgrows the window, Gnosh cuts the oldest rounds out of the context instead of writing a summary, since mem still holds the plan, the results and the thoughts. Where Context-Folding is ahead: it has published results on public benchmarks, and Gnosh does not yet. The newest work near this is NVIDIA's "You don't need long context" (3 November 2026), three days after Gnosh's frames went public. It shows on public benchmarks that an agent loses nothing by keeping its context short, the premise Gnosh is built on, and it keeps the context short by rewriting a summary of its state again and again. How Gnosh goes past that is below. The same move was also put well in words before Gnosh: a blog post by Valentin Sasek (12 April 2026) proposed a "frame stack" in which a sub-conversation returns a value and its work is, in his words, "Structurally absent". It came with one recorded trace and no code. And Playbooks AI (December 2025) ran programs on a call stack, summarizing each finished call. What none of them has is Gnosh's language: the agent opens and closes its frames by writing statements that an interpreter runs. Both are below. ## Side by side | | Context-Folding | Gnosh | |--------------------|--------------------------------------|-------------------------------------| | The move | `branch`, work, `return(message)` | `mem.Push`, work, `mem.Pop(result)` | | Stays in context | the returned message | the pop's result | | Kept elsewhere | nothing the agent can reach | plan, results, thoughts in mem | | Nesting | one level | as deep as the plan | | After the run | ends with the run | the next session picks up | | In parallel | branches tried: about the same score | 3 sessions 2.2–3.4× faster than 1 | | Training | reinforcement learning (FoldGRPO) | none; told how in the prompt | | Room to work | 32K tokens, up to 10 branches | the window; old rounds slide out | | Model server cache | kept: rolled back to the branch | kept: cut back to the push | | Public benchmarks | BrowseComp-Plus, SWE-bench Verified | none yet | ## Context-Folding in more detail Context-Folding ("Scaling Long-Horizon LLM Agent via Context-Folding", Weiwei Sun, Miao Lu and others; arXiv 2510.11967, October 2025; ICML 2026) gives the agent two tools. `branch(description, prompt)` opens a sub-trajectory for a sub-task. `return(message)` folds it, and the main thread goes on with only the message appended. The agent plans in the main thread and works in a branch. While in a branch it cannot open another, "to maintain a clear structure and prevent nested complexity", and the paper names folds within folds as future work. The folding is trained with reinforcement learning (FoldGRPO) on Seed-OSS-36B-Instruct. Its rewards penalize a main thread that grows past half its budget and a branch that strays from its sub-task. With a 32K-token working context and at most 10 branches, the trained agent scores 62.0% on BrowseComp-Plus and 58.0% on SWE-bench Verified. The same model trained to work in one 327K-token context scores 54.0% and 57.4%, and one trained to summarize when its context is full scores 52.7% and 55.0%. The public code, FoldAgent, is a re-implementation that trains Qwen3-8B. It can also run the fold as a prompted workflow on a model not trained for it (their example uses gpt-5-nano). What the two share: the agent chooses where to fold, at the end of a piece of work, rather than wherever the window happens to fill. And the conversation before the fold is left as it was, so the model server's cache of it survives. Context-Folding rolls the KV cache back to the branch point. In Gnosh's server log, the request after a 3K-token pop re-read 2,572 tokens instead of the whole 20K-token conversation. Their results back the idea both rest on: an agent that folds its own finished work does better than one that is summarized when full. Gnosh goes further on where the folded work goes, and who can pick it up. ## Gnosh in more detail In Gnosh the stack is made of the plan. A task is a todo in mem with the todos under it. The agent enters one, works, and pops it with what came of it: ```go mem.Todo("rename the project").Push() // stack: rename-project mem.Todo("rename it in the code") // a todo under it mem.Todo("rename it in the tests") // and another mem.Next() // stack: rename-project › rename-code mem.Pop("go.mod and main.go say gnosh") // done; its work leaves the context mem.Next() // stack: rename-project › rename-tests ``` What a todo learned beyond its result, the agent keeps first as a thought, `mem.Think("the shared port is 8080")`, which outlives the pop. mem is a Gno realm kept on disk with a journal, so the plan, the results, the thoughts and the facts you gave it outlive the session, and a new session starts with what is still open. Several sessions can share one plan and take turns through mem's lock. On one GPU, three sessions finished a task 2.2 to 3.4 times faster than one (https://gnosh.ai/peers.html). The same mem can be a realm on a gno.land chain, worked by many agents at once: https://gnosh.ai/swarm.html replays 1 to 1,000 workers on one plan, on a local chain. When the work outgrows the window before a todo is done, Gnosh slides instead of compacting. The oldest rounds leave the context, those before the first todo first, and the agent is told that mem still has the plan, the results so far and the thoughts. A summary is made only when there is nothing to slide. In one run each with a 24K-token and a 32K-token window on a home machine, a two-session rename passed all six of its checks with no summary written (31 October 2026). The design is in GNOMEM: https://github.com/gnosh-ai/gnosh/blob/main/GNOMEM.md#frames ## Three days later: NVIDIA's "You don't need long context" On 3 November 2026 a team at NVIDIA (Peter Belcak, Pavlo Molchanov and others; arXiv 2611.05306) published "You don't need long context". Gnosh's frames had been public since 31 October, on GitHub, so this is not earlier work. It is here because it is the closest work from a large lab, and its numbers back the premise Gnosh is built on. Their finding: an agent does as well with a short context as with its whole history. They keep the context short in two ways. In the first, when the conversation passes a size threshold, the model writes a compaction of its state and a fresh conversation starts from it. In the second, each conversation takes exactly one action, and the model carries a prose "semantic state" from one conversation to the next. With Claude Opus 4.5 on SWE-bench Verified, the whole history scored 70.0%, compacting at a threshold 74.8%, and one action per conversation 70.2%; on Terminal-Bench 2.1 the three scored 47.2%, 52.8% and 51.8%. With one action per conversation the median peak context was 7K to 9K tokens. They also show why it matters: the deeper a token sits in the context, the more it costs to generate, up to 7 times as much on open models. They propose training new models, "semantic state space models", to keep such a state. And they say plainly that compaction loses information, and loses more each time it compacts an earlier compaction. Gnosh had already gone past that, in six ways: 1. **It cuts where a piece of work ends, not where a count says.** NVIDIA's cut falls at a token threshold, or after every action. Gnosh's falls when a todo is done: the agent entered the todo, did its work, and popped it with its result. The cut follows the structure of the task, which the agent wrote down when it planned. 2. **Nothing is rewritten, so nothing wears away.** NVIDIA's state is prose the model writes again at every compaction, and each rewrite can drop what the last one kept. Gnosh's state is not a summary. It is the plan, the results, the thoughts and the facts, written by the agent as Gno code while it worked and kept in mem with a journal. A pop adds one result and takes the todo's work out of the context; nothing earlier is paraphrased again. 3. **A pop costs nothing.** Each NVIDIA compaction is a model turn that writes the state, and each fresh conversation is read again from its first token. A Gnosh pop needs no model call and no summary, and the conversation before the todo stays exactly as it was, so the model server's cache of it survives (above: 2,572 tokens re-read after a pop instead of 20K). 4. **No new model.** NVIDIA proposes post-training models to keep a semantic state. Gnosh does it now, with the models people already run, a 27B model on a home GPU among them, because the state is code the model already knows how to write, and the harness keeps it. 5. **What was cut is still there, and stale reads go with it.** NVIDIA suggests that a harness could keep every message and let the agent read it back. Gnosh keeps the plan, the results and the thoughts in mem, where the agent queries them in Gno, and keeps the transcript. And when a todo's work leaves the context, so do the files the agent read inside it: before it edits one again it must read it again, so it never edits a file from a copy it can no longer see. 6. **One state, many agents.** NVIDIA's state belongs to one conversation. Gnosh's plan outlives the session, several sessions share it, and the same plan as a realm on gno.land was worked by up to 1,000 agents at once, every todo done exactly once, through killed agents, slow ones and a stopped chain (https://gnosh.ai/swarm.html). | | NVIDIA (3 November 2026) | Gnosh (31 October 2026) | |---------------------|-----------------------------------------|---------------------------------------| | Where the cut falls | at a token threshold, or every action | where a todo is done | | What carries over | prose the model rewrites each time | plan, results, thoughts, as Gno code | | Cost of a cut | a model turn, then a fresh conversation | none: no model call, the cache kept | | Models | today's; new ones trained for it | today's, no training | | Reading back | suggested | mem, queried in Gno; transcript kept | | Agents on one state | one | one to 1,000 | | Public benchmarks | five | none yet | Their benchmarks are what Gnosh still lacks, and they make the fair test easy to state: their harness, their tasks and the same model, with Gnosh's frames in place of compaction. ## Valentin Sasek's frame stack (April 2026) On 12 April 2026 Valentin Sasek, a developer who blogs as @dsl400, posted "Context Engineers: You Are Holding It Wrong!!". His argument: compaction is the wrong tool, because a call stack already solves this. Keep a stack of frames, each a scoped sub-conversation with its own tools and messages and one exit, `ret(value)`. When a frame returns, its messages and tool results leave the parent, the value appears in the parent, and side effects persist; the work is not summarized but gone. His evidence is one trace, four logged requests from his own orchestrator running Gemma 4 26B: the model enters a built-in tool-selection frame, finds a Gitea tool and returns, and the main chat goes on with the tool attached and the search gone. No code was published. It is the same move as a Gnosh pop, and he states it well. Gnosh goes further: 1. **Where frames come from.** His frames are steps his orchestrator defines in advance, like the tool-selection step in his trace. Gnosh's are tasks the agent opens as it works, on a plan it keeps and can change. 2. **What a frame sees.** His frame is a separate sub-conversation with its own instructions. A Gnosh frame continues the same conversation, so the agent keeps everything above it in view, and the pop cuts back to exactly where the frame began, which keeps the model server's cache. 3. **What survives.** His keeps the return value and any tool the frame attached. Gnosh keeps the result, and the plan, the thoughts, the facts and the rules in mem, beyond the session. 4. **When the window fills anyway.** His answer is to scope the work better. Gnosh slides out the oldest rounds, and summarizes only when nothing can slide. 5. **How the agent drives it.** His agent presses fixed tool buttons, `ret` among them. Gnosh's agent writes statements in a language (next section). 6. **Sessions.** He shows one session. Gnosh's plan is shared by sessions on one machine and, on gno.land, by many agents. ## What sets Gnosh apart: frames are statements Context-Folding, Sasek's frame stack, Playbooks AI and NVIDIA's compaction all enter and leave frames through fixed operations: a tool call, a trained action, a program written in advance, or a step the harness takes on its own. In Gnosh the agent writes Gno, and pushing, popping, making a todo, keeping a thought and waiting are functions in that language. That gives three things none of them has: - **Frames mix with ordinary code.** One input can loop to make a todo for each failing test, or pop with a result computed from what it just read: several context operations in one step of the model. ```go for _, t := range []string{"TestParse", "TestLoad", "TestSave"} { mem.Todo("fix " + t) } ``` - **All or nothing.** mem keeps an input's changes only if the whole input succeeds, and only then is the context cut. An input that fails halfway leaves no half-made plan and no half-done pop. - **A real interpreter checks every call.** A mistake comes back as a precise error that shows the agent the right call, instead of a step that silently goes wrong. The nearest earlier work here is CodeAct (2024) and Recursive Language Models, where the model writes code, but on data, not on its own context; and Playbooks AI, whose programs run on a call stack, but are written by a developer in advance, and each finished call is summarized. We found nothing earlier in which the model changes its own context and plan with statements that an interpreter runs. ## The others **AgentFold** (Alibaba's Tongyi Lab; arXiv 2510.24699, October 2025; ICLR 2026). At each step the agent may fold a range of its past steps into a summary, lightly or deeply. The agent picks what to condense, which beats a summary forced by a full window, but it is still a summary. What it leaves out is gone, nothing is kept outside the context, and there is no stack of open work. **Recursive Language Models** (arXiv 2512.24601, October 2025) and **Prime Intellect's RLM environment** (January 2026). The model keeps only the question in its window, reads a huge input through a Python session, and hands pieces to fresh copies of itself. Prime Intellect's version goes one level deep, with no stack and no pop, and "never actually summarizes context". It answers a different problem: inputs too big to read, not tasks too long to keep in mind. **Subagents** (Claude Code, Codex and others). A sub-task runs in a fresh, separate context and sends back a report. That is close to a pop with a summary, but the subagent starts blind, sharing none of its parent's context, and the report is all that survives. A Gnosh frame works inside the same conversation, with the plan and the earlier results in view. **Rewind and forking** (Claude Code's /rewind, OpenCode, Pi; HumanLayer's "context forking", May 2026). A person cuts the conversation back to an earlier point. It is a pop chosen by the user, and nothing of the removed work is kept. **Compaction and context editing** (Claude Code's /compact, Codex, Factory; Anthropic's context editing, September 2025). When the window fills, a summary replaces the conversation, or old tool results are cleared. The cut falls where the window filled, not where a piece of work ended, and the summary loses detail. On a home GPU it is also slow. On Gnosh's test machine (Qwen3.8 27B on a home AI box), the median summary is about 4,500 tokens and takes about five and a half minutes to write. Gnosh keeps compaction only for when there is nothing to slide. **Memory tools and MemGPT/Letta** (Anthropic's memory tool, September 2025; MemGPT, 2023). These keep things across conversations: files the model reads and writes, or old messages paged out to searchable storage with a running summary. They are durable, but they sit beside the context rather than shaping it. Nothing in them closes finished work out of the context, and MemGPT pages messages out by age when the window fills. In Gnosh the frames on the stack are the todos in mem, so finishing a todo is what moves its work out of the context and its result into the plan. **Playbooks AI** ("Stack-Based Context Management", December 2025; the project wound down in April 2026). Playbooks nest like function calls, each in its own frame, and when one returns, its steps are replaced by a short summary and its return values. The stack is a program's, written by a developer, not the agent's own plan, and a finished call is summarized, not cut. **A request that went unbuilt.** Claude Code issue #5329, "Hierarchical Context Management (Conversation Stack)" (August 2025), asked for /push and /pop commands, a pop coming back "with compressed summary", and a stack kept across restarts. It was closed as not planned in January 2026. Those were commands for the user, not tools for the agent. ## Where Context-Folding is ahead Evidence. Context-Folding has scores on two public benchmarks, against baselines on the same model, and a training method that teaches the model when to fold. Gnosh's frames are taught by the prompt alone, and its evidence so far is runs on its own machines, like the window runs and the peers runs above. The fair test, their benchmarks with one model and Gnosh's frames on and off, has not been run yet. ## Missed something? This is a few days of searching, not a literature review. If we missed work or got something wrong, open an issue: https://github.com/gnosh-ai/gnosh/issues ## Sources - NVIDIA, "You don't need long context": https://arxiv.org/abs/2611.05306 - Valentin Sasek, "Context Engineers: You Are Holding It Wrong!!": https://medium.com/@dsl400/context-engineers-you-are-holding-it-wrong-878c0a38b735 - his trace: https://gist.github.com/dsl400/7f84d39542f7b596ce848a74a1adea39 - Playbooks AI, "Stack-Based Context Management": https://website-one-tau-69.vercel.app/blog/stack-based-context-management - CodeAct: https://arxiv.org/abs/2402.01030 - Context-Folding: https://arxiv.org/abs/2510.11967 - project page: https://context-folding.github.io/ - code: https://github.com/sunnweiwei/FoldAgent - AgentFold: https://arxiv.org/abs/2510.24699 - Recursive Language Models: https://arxiv.org/abs/2512.24601 - Prime Intellect: https://www.primeintellect.ai/blog/rlm - HumanLayer, context forking: https://www.humanlayer.dev/blog/context-forking-to-save-time-trouble-and-tokens - Anthropic, context editing and the memory tool: https://www.anthropic.com/news/context-management - MemGPT: https://arxiv.org/abs/2310.08560 - Claude Code issue #5329: https://github.com/anthropics/claude-code/issues/5329 - Gnosh: https://github.com/gnosh-ai/gnosh - the frames, in the README: https://github.com/gnosh-ai/gnosh#frames-no-more-compaction - peers: https://gnosh.ai/peers.html - swarm: https://gnosh.ai/swarm.html -- https://gnosh.ai · https://github.com/gnosh-ai/gnosh