TL;DR
LLM agents are notorious memory hogs because they carry around massive execution histories that clog up a GPU’s limited "short-term memory" (the KV cache). Contexture is a smart, runtime-level garbage collector that identifies redundant information—like an old file read that’s been superseded by a newer edit—and evicts it only when the GPU is actually feeling the squeeze. By bridging the gap between what the agent is doing and how the GPU is feeling, it boosts serving throughput by up to 73% without making the agents any dumber.
What Problem Does This Paper Address?
When you use an LLM agent (like a coding assistant), it doesn't just send one prompt. It operates in "rounds": it thinks, calls a tool (like reading a file), gets an output, and then sends the entire history back to the model for the next step. As the task goes on, this history balloons.
In a professional serving environment, multiple agent sessions share the same GPU. The GPU stores the "Key-Value (KV) cache"—essentially the processed version of the conversation history—in its high-bandwidth memory (HBM). As shown in the agentic serving stack (Figure 1), this memory is finite.
The authors identify a "KV capacity bottleneck." Once the memory pool is full, the system starts preempting (pausing) sessions and recomputing their caches later. This leads to a death spiral where the GPU spends more time re-calculating old thoughts than generating new ones. Existing solutions either summarize history (which is slow and can lose vital details) or prune tokens based on "importance" (which ignores whether the GPU actually needs more space right now).
Methods
Contexture introduces a "harness-agnostic" architecture that lives inside the serving runtime (like vLLM). It works through three main components:
- Session Tracker: It watches the "tool calls" (like shell commands or file reads). It uses a concept called supersession: if an agent reads
app.pyin round 1, but then edits and reads it again in round 5, that first observation is now redundant. The tracker identifies these "removal candidates" automatically without needing extra LLM calls. - Policy Actuator: This is the brain. It looks at the global state of the GPU memory. It won't evict context just because it's old; it waits until the memory pool is under pressure (e.g., >80% full). It also calculates a "cost-benefit" analysis: will evicting this span save enough memory to justify the "re-prefill" (the compute cost of re-processing the remaining history)?
- Context Filter: When a request is sent to the model, this filter snips out the committed redundant spans from the prompt. Crucially, the agent's "harness" still sees the full history, but the "model" gets a lean, mean version of it.
The system also uses a Grace Window (defaulting to 2 rounds), ensuring that very recent information isn't deleted before the agent has a chance to act on it.
Datasets
The authors evaluated Contexture using two long-horizon agent benchmarks that simulate real-world complexity:
- Terminal-Bench 2.1: A benchmark for agents performing realistic tasks in command-line interfaces.
- SWE-Atlas-QnA: A dataset focused on software engineering tasks.
They tested these across two different agent frameworks (Hermes and OpenClaw) and two powerful models (Qwen3.8-27B and the mixture-of-experts Qwen3.6-35B-A3B).
Key Insights and Ideas
- The 64% Rule: By tracing tokens back to tool operations, the authors found that a staggering 64% of tokens in final session histories are actually redundant removal candidates. This is the "aha!" moment: we are wasting a massive amount of expensive GPU memory on "stale" observations.
- Global vs. Local Visibility: You can't make a good eviction decision by looking at one session in a vacuum. Contexture succeeds because it knows both the semantic value of the tokens (from the tool calls) and the physical state of the GPU (from the runtime).
- The Re-Prefill Trap: Deleting a middle chunk of a conversation history invalidates the cache for everything that comes after it. Contexture is smart enough to perform "cold commits"—evicting context only when the cache would have to be recomputed anyway—to minimize wasted cycles.
Key Results
- Throughput: Contexture improved throughput under Service Level Objectives (SLO) by 20–73% compared to the best existing baselines (like standard compaction or AgentDiet).
- Energy Efficiency: It reduced GPU energy consumption per completed session by up to 11%. Even though it occasionally forces the GPU to re-process some text, the overall efficiency gain from not having to pause and restart sessions is a net win.
- Accuracy: Unlike "observation masking" (which aggressively hides old data and can tank accuracy by up to 28 points), Contexture maintained high task accuracy, even showing a slight mean improvement (1.4 points) because it keeps the model focused on relevant, non-redundant context.
Limitations and Future Work
- Tool Scope: The current prototype primarily handles file-system and sandbox tools. It doesn't yet have specific "supersession" rules for external web APIs or more complex multi-agent communication protocols.
- Structured Output Dependency: The system relies on being able to parse tool calls and outputs. If an agent uses a highly non-standard or unstructured way of calling tools, the Session Tracker might struggle to identify what has been superseded.
- Future Directions: The authors suggest integrating this with even more advanced KV management techniques, like KV offloading to host memory, to further push the boundaries of how many agents we can pack onto a single GPU.
Summary updated