🚀NEW COURSEVibe Coding AI Apps with Claude Code 🤖✨Enroll now
Memory

Context Management as Code

First page
Context Management as Code
Paper summary

Every memory system asks you to design a schema up front, then rewrite it when the agent starts doing something you did not anticipate. Scroll, from Alibaba, removes the schema entirely and hands context construction to the model as a programming problem.

Ask this paper

Key points
01

State lives outside the prompt: Each session is backed by an append-only event log and a sandboxed, persistent Python kernel. Tool outputs, retrieved history, and derived state bind to typed variables across model calls instead of being serialized into the prompt every turn.

02

Only printed projections cross the boundary: Model-written code searches and transforms that state, and just the explicitly printed output enters the working view. The event log keeps lossless ground truth, so nothing gets committed to a compressed form before you know what will matter.

03

Eviction stays recoverable: When the working view nears its budget, stale spans are evicted but remain retrievable. An eviction index keeps compact landmarks tied to exact event-log addresses, so the agent navigates back to a region instead of searching the whole log.

04

Why it matters: With Qwen3.8-Max it reaches 94.8% on LongMemEval_S, 73.1% on BEAM_10M (5.1 points over the best published memory system), and 86.7% on LOCA_256K. Because context management runs as code, it inherits every future improvement in model coding ability.

Every Monday
Get next week’s papers.
Subscribe on Substack