Shared Dependency Caching Across Parallel Agent VMs
Shared caching eliminates redundant dependency installation as agent fleets scale in parallel.

Shared dependency caching across parallel agent VMs answers a structural cost problem: as coding agent fleets grow, the time spent installing dependencies before useful work begins dominates wall-clock time and wastes identical package fetches. The pattern is to install once into a prepared workspace, then materialize private writable copies for each concurrent agent, preserving isolation without repeating the setup tax. Run this way, parallel execution no longer multiplies installation work: the fleet's cold start is one preparation phase, then near-instant fan-out.
Why dependency installation becomes the dominant cost as agent fleets grow
A single agent on a single VM conceals the cost. One install happens, it takes some seconds or minutes, and then the agent works. Nothing about that experience signals a problem, because the setup tax is paid once and absorbed into the run.
At fleet scale the arithmetic changes. Each agent resolves and installs its own dependencies before investigating code, so the same package graph is fetched, unpacked, and written to disk again and again. The cost is doubled waste: redundant network and disk work on one side, and idle agents on the other, waiting through setup when they might already be producing findings. Local hardware shows the ceiling early, because memory, CPU, and disk I/O cap how many concurrent installs a machine can sustain. Cloud infrastructure removes that ceiling but not the per-agent install itself, so the tax survives and compounds as the fleet grows. The Sandy Reviews specification names this precisely: logic and security agents are serialized in part because running them in parallel would multiply installation work, and the fix requires separating dependency preparation from agent execution.
What "install once, fork many" means in structural terms
The solution is a two-phase structure. In the preparation phase, a single workspace is fully installed: dependencies resolve, packages download and install, and the repository is indexed. In the fan-out phase, each admitted agent receives a private writable copy materialized from that prepared state, and the install is never repeated.
The Sandy specification states the requirement directly: dependencies are installed once before agent fan-out so that parallel execution does not multiply installation work. Within this pattern there are two distinguishable cache contributions, and the distinction matters for both cost and correctness. Each one handles a different part of the setup tax, so teams can adopt the lighter form first without committing to the stronger isolation guarantees the heavier form demands.
Why agents need isolated writable workspaces even when sharing a common installation
Sharing an installation base and sharing a writable workspace are incompatible goals. Agents that write to the same filesystem paths corrupt each other's build state, invalidate test results, and produce findings that cannot be attributed to any single agent. The failure modes are concrete. One agent's build artifacts overwrite another's mid-investigation. Test runs leave state that contaminates the next agent's assertions. Index locks contend, serializing what was meant to run in parallel. Findings lose their provenance because workspace writes are commingled.
The Sandy specification encodes this as a pair of requirements that pull in opposite directions. Each agent needs its own writable source and test workspace so that another agent's build or test cannot interfere with its investigation. At the same time, each agent must see the same reviewed revision and pinned sibling sources as the others so that all investigate a consistent set of code. Consistency demands a shared base. Isolation demands private writes. The solution must satisfy both at once, which is why the pattern separates the immutable prepared state from the mutable per-agent layer. Isolation is also a security requirement, not merely a correctness one: cache artifacts must exclude credentials and mutable review outputs so that reused downloads neither expose authentication material nor carry results between reviews.
Git worktrees as the source-control layer of per-agent isolation
Git worktrees resolve the tension at the source-control layer cheaply. Each parallel agent holds its own private branch and index, but all agents share a single underlying object store. Per-agent checkout becomes instantaneous and storage-negligible. Cloning the repository for every agent would duplicate the full object store N times, which at fleet scale is expensive and slow. A linked working directory instead carries its own index and branch pointer: uncommitted edits in one worktree are invisible to every other, and index locks no longer contend across agents.
Because the object store is shared, history, remotes, and blobs are fetched once. The source-control layer is now solved, and its cost is effectively zero. The expensive question moves entirely to the dependency layer, where installed state is heavier than source files and cannot be materialized with a pointer swap alone.
How the dependency layer is isolated: snapshots, copy-on-write, and layered images
Making installed dependency state private per agent without re-installing it requires either a copy-on-write filesystem snapshot or a composable image layering scheme. In the snapshot approach, the prepared workspace is snapshotted and each agent VM boots from it. Writes land in each VM's own copy-on-write layer while reads of unchanged files hit the shared base without penalty. In the layered image approach, the base OS, workspace and dependencies, and toolkits are kept as separate cacheable image layers, and agents compose the stack at boot from cached layers rather than rebuilding it.
Layering matters at scale because a monolithic image creates a combinatorial rebuild burden: upgrading a base image forces rebuilding every workspace combination on top of it. Composable layers break that coupling, allowing a small number of shared base images to combine with many task-specific workspaces. The cold-start fallback is non-negotiable: when a cache is missing or unusable, the system falls back to a full installation, because cache availability must never determine whether a review can run.
Internet access, the setup phase boundary, and where shared caching produces the greatest return
Cloud agent environments that block network access during execution force all package fetching into a pre-agent setup phase, and that phase is precisely where a shared cache accelerates the most. The Codex cloud task design illustrates the boundary: agent internet is blocked by default during execution, setup scripts retain internet access for dependency installation, and internet can be re-enabled per environment with domain and method controls. This is a deliberate security posture, because prompt-injection and exfiltration risks are documented when internet remains enabled during the agent phase.
The consequence for caching is structural. If setup is the only phase where packages can be fetched, a cache hit in setup eliminates the only window where network latency matters. A cache miss means a serialized fetch across the public registry, and a cache hit becomes a local copy. The Sandy specification reinforces the design: setup scripts run with internet access, and the architectural goal is to complete all dependency work before agents fan out, with cached package downloads accelerating repeat preparation so reviews spend less time fetching unchanged dependencies. The network boundary makes the install-once pattern load-bearing rather than optional: it is the only design that respects the security posture while keeping parallel agents from paying the fetch cost individually.
Keeping parallel agents from corrupting shared authentication and build state
Parallelizing agents over a shared runtime introduces two coordination hazards that isolation alone does not resolve: credential refresh races and attribution collapse when findings from concurrent agents combine. If each parallel agent owns its authentication refresh cycle, concurrent rotations of the same credential conflict. The Sandy specification solves this by serializing whole reviews around the dedicated CI authentication stream, so one runtime owns refresh and concurrent agents cannot race on rotation.
Attribution collapse is the second hazard. When agents complete in unpredictable order and a synthesizer combines their outputs, findings can lose their provenance. The specification requires findings attributed to the agent that produced them, so that completion order or model-provided labels cannot change provenance, and separate per-agent run status, timing, tool activity, and usage. Partial failure handling is equally important: one agent's timeout must leave healthy agents running, so an isolated problem does not discard the whole review. That requires the orchestrator to manage agent lifecycles independently rather than as a group. A bounded concurrency setting guards against additional personas creating unbounded resource or request pressure, and timeout budgets should start when an agent's investigation begins, not when it enters a queue, so agents waiting for a concurrency slot are not penalized for orchestration latency they did not cause.
How workload-aware caching extends the pattern beyond the setup phase
The logic that makes installed-dependency caching valuable applies further up the stack: when multiple concurrent agents perform structurally identical computations, caching intermediate results eliminates redundant work at every layer of the pipeline. Research from the University of Minnesota and Google demonstrates this for DAG-structured multi-agent systems. Workload-aware caching is also complementary to parallel agent execution: each targets a distinct efficiency bottleneck, so combining them compounds the gain rather than trading one off against the other.
The mechanism is visible in a financial analysis pipeline where "What was Company X's revenue?" and "What was Company X's profit margin?" share identical initial steps: retrieving financial statements, parsing documents, and extracting standard fields. Caching those shared steps means neither query pays for them twice. The coding-agent analogue is direct: logic and security agents investigating the same repository may share parsing, indexing, and context-retrieval steps, and those are candidates for intermediate result caching layered on top of dependency caching. This is the same principle applied higher in the pipeline, not a replacement for the install-once pattern at the foundation.
What the pattern requires from the environment the agents run in
Shared dependency caching with per-agent isolation requires the agent environment to provide real VM-level isolation, pre-loadable dependency state, and the ability to snapshot or layer that state before fan-out. Shared containers or thin sandboxes cannot reliably provide these capabilities, because containers share the host kernel, so isolation guarantees are limited between concurrent agents running untrusted or AI-generated code. The environment must support pre-loading: agents need to arrive at a VM that already has the team's dependencies, tooling, and repository state installed, not a blank machine starting from scratch. Agents must be able to install packages, run services, drive a browser, and verify their own work inside the VM, making the environment functionally equivalent to a developer machine rather than a restricted sandbox that only runs pre-approved commands.
Full per-run attribution depends on the environment tracking each VM's lifecycle independently: which agent, which harness, which model, which credential, and for how long. That tracking is what makes the separate per-agent run status, timing, tool activity, and usage requirement operationally achievable. The requirement that agents see identical code while their writes never interfere is a design principle baked into cloud agent platforms: Replicas isolates each agent task in its own VM to prevent workspace corruption while maintaining consistency across the fleet. Replicas builds each environment from a definition a team establishes once, with dependencies and tooling installed at setup, which makes the install-once, fork-many pattern a first-class operational primitive rather than a workaround. The agent environment is as important as the caching strategy itself, and the pattern only holds on infrastructure designed to support it.
The cache key, the cold-start fallback, and the operational checklist for teams adopting this pattern
Teams adopting shared dependency caching across parallel agent VMs need to get four operational decisions right: cache key design, cold-start fallback behavior, concurrency bounds, and attribution wiring. Any one of these wrong defeats either the correctness or the performance goal. The cache key must encode repository, platform, runtime, package manager, and lockfile, because a key that omits the lockfile can serve a cache built against a different dependency graph, a correctness failure that looks like a performance win until it produces wrong findings. Cold-start fallback is simple to state and easy to forget: cache unavailability must never prevent a run, so a miss falls back to a full install and the review proceeds, since the cache is an accelerator rather than a prerequisite.
Credential isolation assigns authentication refresh to one runtime so concurrent agents never race on token rotation, and credentials remain excluded from cache artifacts entirely. Attribution wiring tracks each agent's run record independently from the moment it starts rather than assembling it after completion from combined output, which is what makes per-agent cost measurement and finding provenance possible. A concurrency cap bounds parallel agents per review or task batch, preventing additional personas from creating unbounded resource and API quota pressure. Finally, serial execution remains an explicit fallback: parallel caching should be validated against serial baselines before it becomes the default, confirming that elapsed time is lower and finding quality is preserved.


