Manuscript Offprint

arXiv:2609.11294

Memory Compression for High-Fanout Agent Sandboxes

Mengming Li, Ceyu XU, Qijun Zhang, Jiangnan Yu, Xiangfeng Sun, Haohui Mai, Zhiyao Xie

Mengming Li ∗^{*}

mengming.li@connect.ust.hk

HKUST

Jiangnan Yu

jyucr@connect.ust.hk

HKUST

Ceyu Xu ∗^{*}

eeentropy@ust.hk

HKUST

Xiangfeng Sun

xsunbv@connect.ust.hk

HKUST

Qijun Zhang

qzhangcs@connect.ust.hk

HKUST

Haohui Mai

Haohui@ust.hk

HKUST

Zhiyao Xie †^{\dagger}

eezhiyao@ust.hk

HKUST

Abstract

High-fanout agent workloads create a growing memory bottleneck because a single task may spawn many concurrent sandbox sessions. Yet these sandboxes are far from independent: they originate from a shared template and execute related trajectories, exposing substantial template-relative and cross-sandbox memory redundancy. Conventional memory compression is poorly matched to this setting in three fundamental dimensions: how to compress, because they fail to exploit similarity across non-identical sandbox pages; what to compress, because they control page-fault overhead through conservative page selection; and when to compress, because compression is either triggered by memory pressure or performed without awareness of agent execution phases.

We present AgentZip, the first memory compression system designed specifically for AI-agent sandboxes. AgentZip introduces compression mechanisms that exploit both the template-relative and cross-sandbox redundancy. It broadens the compression scope to any page with a profitable representation and shifts overhead control from compression-time page selection to restore-time prefetching. It further aligns expensive compression with LLM waiting periods to avoid interfering with foreground tool execution. Across LLM training and inference workloads, AgentZip reduces sandbox-owned memory by up to 8.7×8.7\times, compared with 2.1×2.1\times for the Linux configuration. Restore prefetching and agent-execution-aware scheduling reduce the slowdown of aggressive compression from as high as 3.1×3.1\times to 1.40×1.40\times while retaining nearly all of its memory-saving benefit.

1 Introduction

Modern AI agents no longer merely produce text. To resolve a software issue, analyze a dataset, or operate a computer, an agent typically issues shell commands, edits files, installs dependencies, and runs tests [7, 22, 26]. Because these actions execute untrusted code and mutate persistent state, agent

Figure

Figure 1. Similarity between sandboxes creates opportunities for inter-sandbox memory compression.

platforms nowadays choose to run every action inside a sandboxed execution environment that provides isolation and lifecycle control [2, 27]. As a result, the agent sandbox is no longer a peripheral part of the serving stack: it is where agent execution actually happens.

Memory as bottleneck due to scaling. Agentic workloads are increasingly high-fanout: a single task spawns many sandboxes rather than one. As shown in Figure 1, during reinforcement learning (RL) training, an agent samples tens of independent trajectories per task so that an RL reward model can score them [21, 29]. During inference, multi-agent workflows run several candidate sessions concurrently to speed up parallel trial-and-errors [18]. In summary, fanout enables productive LLM training and inference, but it also makes them expensive. Specifically, it changes the unit of provisioning: a host no longer backs one sandbox per task, but tens of concurrent sibling sandboxes. Crucially, the resource that usually runs out first is memory instead of compute. Sandboxes spend much of their life blocked on model output: between two tool calls, a sandbox sits idle waiting for the

∗^{*}Mengming Li and Ceyu Xu contributed equally to this work.

†^{\dagger}Corresponding author.

LLM to decode the next command, so cores stay available while memory does not.

Opportunity: Redundancy in Memory. If each sandbox occupies MsM_s bytes and a host devotes altogether MhM_h bytes to sandboxes, concurrency is capped near Mh/MsM_h/M_s. However, this linear scaling is far worse than the workload deserves. Sibling sandboxes that fan out from one task are not independent: they are cloned from the same template image, open the same repository, import the same libraries, and run overlapping command sequences. Their memory redundancy comes from two complementary sources: 1) Template-relative similarity. It arises because sandboxes are cloned from a shared template, and many private pages remain close to their corresponding template pages after copy-on-write. However, this similarity can weaken as execution progresses and sandboxes accumulate more private states. 2) Cross-sandbox similarity. It provides a complementary source of redundancy: sibling sandboxes executing related trajectories often develop similar runtime states even after they have diverged from the original template. Section 6.5 shows both forms of similarity are substantial, with 76–96% of pages exhibiting template-relative or cross-sandbox redundancy in our measurements.

At a high level, a memory compression system must answer three fundamental questions: 1) How to compress, which determines which compression algorithms and representations are used to exploit available redundancy. 2) What to compress, which determines which memory pages are selected as candidates for compression. 3) When to compress, which determines when compression is performed and physical pages are reclaimed. We point out that all these three fundamental decisions in today's mainstream memory compression mechanisms are poorly matched to high-fanout agent sandboxes, as we elaborate below:

① [How]: Wrong redundancy model. General-purpose compressors such as zswap [1, 4] and zram [16] only exploit intra-page redundancy. These general compressors compress each page independently and therefore cannot exploit its similarity to the original template or to runtime content in sibling sandboxes. Page-level deduplication such as KSM [14] exploits inter-page redundancy, but requires exact page equality. Most of such exact-sharing opportunities have already been covered by copy-on-write at sandbox creation. ② [What]: Wrong compression scope. Existing compression systems [9, 11, 20] restrict compression primarily to pages unlikely to be accessed in the near future, using access hotness or predicted reuse to control page-fault overhead. This creates an inherent trade-off: compressing warmer pages exposes greater memory-saving opportunities, but also increases costly page faults. Accurately identifying which warm pages can be compressed is difficult. Thus, conservative selection becomes inevitable, leaving many profitable compression opportunities wasted. ③ [When]: Wrong timing. Zswap [1, 4] operates only reactively on the swap-out path and under memory pressure. This compression timing is poorly matched to reducing the average sandbox memory footprint over its lifetime, because compressible pages may remain resident for most of a session.

This paper presents AgentZip, a sandbox memory compression system that rethinks these three fundamental design choices for high-fanout agent workloads.

[How]: Sandbox-aware redundancy model. AgentZip directly exploits the two forms of memory redundancy exposed by sandboxes. 1) For template-relative similarity, it represents a sandbox’s private page as a compact delta from its corresponding immutable template page. 2) For cross-sandbox similarity, it builds shared dictionaries that capture common byte patterns across sibling sandboxes and uses these dictionaries to encode candidate pages. These mechanisms broaden the exploitable inter-page redundancy beyond exact page equality. AgentZip further combines them with lightweight intra-page compression and selects the most space-efficient representation for each page.

[What]: Unlimited compression scope. AgentZip no longer restricts compression eligibility based on page hotness or predicted reuse. Instead, any page is eligible for compression as long as it can be compressed profitably, including warm pages that are likely to be accessed again. This broader scope is enabled by a new compression paradigm: Instead of avoiding future page faults through selection at compression time, AgentZip allows compressing warm pages by mitigating page faults at page restore time through prefetching. At restore time, AgentZip predicts which compressed pages will be needed soon and prefetches them before demand.

[When]: Agent-execution-aware compression timing. Rather than waiting until memory pressure to start compression, AgentZip proactively aligns compression with the agent execution lifecycle: it performs lightweight candidate discovery during tool execution and moves expensive compression into LLM waiting periods. This lifecycle awareness avoids interfering with foreground tool execution while reducing the time-averaged sandbox memory footprint.

The contributions of this paper are summarized below:

• We present AgentZip, the first memory compression system that exploit the redundancy within AI-Agent sandboxes. We identify sandbox memory as a first-order scaling bottleneck in high-fanout agent workloads and show that sandbox-specific redundancy and execution structure create substantial opportunities beyond conventional memory compression.

• We design a sandbox-aware compression algorithm that exploits both template-relative and cross-sandbox redundancy, with lightweight local compression. By capturing redundancy that existing mechanisms miss, AgentZip reduces sandbox-owned memory by up to 8.7×8.7\times and four times more than Linux configuration.

• We rethink how compression overhead is controlled. AgentZip decouples compression from future page faults by aggressively compressing profitable pages and predicting their restores before demand, while aligning expensive compression with repeated LLM waiting periods rather than memory pressure. These techniques reduce the slowdown of aggressive compression from 3.1×3.1\times to 1.40×1.40\times while retaining nearly all of its memory-saving benefit.