Skip to main content
Back

RAMPART Lets Smaller Models Beat Larger Ones by Controlling Context Order

RAMPART treats LLM context assembly like a compiler pass, using five primitives to control what goes in, where, and when — with measurable gains across five models.

Pro

Paper, Full Access
  • RAMPART is a compile-time memory model for LLM agents that treats context assembly as a programmable operation over a named block registry.
  • Five primitives (promote, gate, write, evict, rollback) control what enters the prompt and where, at zero token cost.
  • Task success collapses past block position 7-12; grouping critical blocks with semantic neighbours lifts pass rates by tens of percentage points.
  • Block grouping raises Mistral-7B's pass rate ~5x at the hardest registry size; a smaller model with the intervention can beat a larger model without it.
  • Relevance gating cuts prompt cost by 67.8% while recovering 83% of full-context performance; schema eviction guarantees 0% tool invocations.
  • The effect is replicated across Qwen2.5-7B, Llama-3.1-8B, Mistral-7B-v0.3, and Qwen3-14B — paper on arXiv.

Every LLM agent has a dirty secret: it doesn't actually control what goes into its own context window. Tools dump outputs, RAG pipelines inject retrieved chunks, system prompts pile up , and the model just gets whatever lands in the buffer. A new paper from Nikodem Tomczak proposes RAMPART, a compile-time memory model that treats context assembly as a first-class, programmable operation rather than an afterthought.

The problem hiding in plain sight

LLM agents increasingly operate in settings where a single context window is far too small to capture everything relevant. Memory , the ability to persist, organize, and selectively recall information across interactions , is what turns a stateless text generator into a genuinely adaptive agent. But most frameworks still treat context construction as a passive process: append what you have and hope the model figures it out.

The deeper issue is positional. The "lost-in-the-middle" effect is a demonstrated phenomenon where LLMs perform significantly worse when relevant information is placed in the middle of the input context rather than at the beginning or end. LLMs exhibit a U-shaped attention bias where the tokens at the beginning and end of their input receive higher attention, regardless of their relevance. This isn't a quirk of one model family , it is not a minor edge case; it affects every production LLM.

Treating the LLM context window like persistent storage causes most agent failures. Most production agent failures are not model failures but memory architecture failures , and the fix requires managing the context window the way an operating system manages RAM: with deliberate control over what goes in, what stays, and what gets evicted.

RAMPART: context as a compiled artifact

RAMPART is a compile-time memory model and pure in-RAM block registry for LLM-based agents. Context assembly is a programmable runtime operation where content is compiled from a structured registry under explicit policy for ordering, inclusion, and eviction. The key mental model: instead of building a prompt by concatenation, you maintain a named registry of content blocks and then compile the prompt from that registry right before inference.

Five composable primitives , promote, gate, write, evict, rollback , act on named addressable blocks before compilation at zero prompt-token cost. Each primitive is a pure in-memory operation that costs nothing in tokens:

  • promote , moves a block (or group of blocks) to a higher-priority position in the compiled output
  • gate , conditionally includes a block only if it passes a relevance check against the current query
  • write , adds or updates a named block in the registry
  • evict , removes a block from the registry entirely before compilation
  • rollback , reverts the registry to a prior state

Provenance tags and non-evictable authorship flags implement a permissioned memory model with block-level ownership. This means you can mark certain blocks (say, a safety policy or a user identity block) as non-evictable, so no downstream agent or tool call can accidentally overwrite them.

Four panel charts showing task success fraction vs. critical block position across different registry sizes and single vs. cluster placement modes

What the experiments actually show

The paper runs controlled probes , synthetic tasks where a "critical block" (the one the model needs to succeed) is placed at varying positions in the registry. The results are stark. Compile-time placement and the structural relationship between blocks and the task query affect task success, with the cliff falling at roughly the seventh block position when the task follows the registry and the twelfth when it precedes. In other words: if your critical context is buried past position 7, task success collapses , unless you do something about it.

The "something" RAMPART proposes is block grouping with content priming. Rather than promoting a single critical block, you group it with semantically adjacent neighbours and promote the whole cluster. Grouping the critical block with content-adjacent neighbours and promoting the group as a unit lifts task success by tens of percentage points at positions where single-block placement fails.

Cross-model replication across Qwen2.5-7B, Llama-3.1-8B, Mistral-7B-v0.3, and Qwen3-14B confirms the effect is not model-specific. The content-priming effect appears at the same absolute positions across families, with magnitude varying with model strength. Most strikingly: block grouping raises Mistral's mean pass rate roughly fivefold at the hardest registry size, and a smaller model with the intervention can outperform a larger model without it in the mid-registry zone.

The other three results worth knowing

Beyond block placement, the paper reports three additional findings that matter for production systems:

  • Relevance gating: Relevance gating reduces prompt cost by 67.8% while recovering 83% of the promoted-condition success rate. You can skip most of your registry for a given query and still get nearly full performance.
  • Schema eviction: Schema eviction produces 0% invocations against 100% with the schema present, a property policy-based approaches cannot guarantee by construction. If you want a tool to be completely invisible to the model, evicting its schema is the only reliable way , soft prompting can't guarantee this.
  • Multi-agent coordination: Shared-registry coordination reduces inter-agent communication to a method call at zero coordination token cost. Multiple agents sharing a registry coordinate through memory reads and writes rather than through message-passing tokens.

How it fits into the broader landscape

Early memory-augmented systems typically log past interactions or retrieved documents in a buffer and naively prepend them to the prompt, which quickly becomes inefficient and noisy as the context grows. Early agent memories largely followed a static RAG-style design, treating memory as an append-only repository queried by global similarity search, which limits learning from feedback and consolidation over time. RAMPART's contribution is orthogonal to retrieval quality , it's about what happens after retrieval, when you're deciding what to actually send to the model and in what order.

The compile-time framing is the real conceptual shift. Beyond a moderate window size, effective working memory and architecture become the real bottlenecks. Packing more tokens often causes models to lose earlier details or fall back on shallow pattern matching. RAMPART doesn't fight the context window size battle , it works within any window by making placement a controlled, deterministic operation.

What it's not (yet)

A few honest caveats. The experiments use quantized 7-8B models in controlled probe settings, not real-world agentic tasks like code generation or multi-step tool use. The "critical block" setup is synthetic by design , real registries will have fuzzier relevance boundaries. The paper also doesn't report wall-clock latency overhead for the compile step itself, though since all operations are pure in-RAM, it should be negligible. No code repository is linked in the paper at this time.

The finding that block grouping lets a smaller model beat a larger one is the headline result, but it comes with an asterisk: it holds in the "mid-registry zone" under controlled conditions. Whether this generalizes to production prompt complexity is an open question.

What you can take away right now

Even without a RAMPART implementation, the paper's empirical findings are immediately actionable:

  1. Don't let your most critical context block end up past position 7-12 in a long prompt , promote it explicitly.
  2. Group related blocks together rather than scattering them; semantic adjacency amplifies attention.
  3. Use conditional inclusion (gating) aggressively , dropping 68% of your prompt tokens while keeping 83% of performance is a real trade-off worth making.
  4. If you need a tool to be truly invisible to the model, remove its schema from the context entirely; don't rely on instruction-based suppression.
  5. For multi-agent systems, a shared in-memory registry is a cleaner coordination primitive than token-based message passing.

The core insight RAMPART formalizes , that context assembly should be a deliberate, policy-driven compilation step rather than an append operation , is likely to influence how agent frameworks think about prompt construction going forward.