Copula: Sound Sharing of Stochastic Nodes Across Runs of Agentic Systems

Sun, Bowen, Zheng, Haizhong, Chen, Beidi, Xiao, Chaowei

–arXiv.org Artificial Intelligence 

Agentic systems chain model and non-model calls, and are rerun after edits, as replicates and comparisons, concurrently and after crashes. We model a run as a DAG whose nodes are these calls. Because runs repeat, nodes meet the same inputs again, and caching could save their tokens, compute and time. But many nodes are random, and storing one output per input turns repeated calls into copies, while voting and replicates need them independent. Recent LLM caches therefore number repeated calls: the k-th identical call within a run reads the k-th stored sample, drawn only if missing. Repeated calls stay independent, but a replicate meant to be averaged rereads earlier runs' samples instead of drawing fresh ones. They also number only model calls, so a random non-model call upstream changes every downstream request, and costly ones, such as code execution, web APIs and simulators, rerun. Key observation: sharing a node's sample never changes the distribution any one run sees, only the correlation between runs. Whether runs share is thus an experimental-design choice set by how outputs are used: sharing is a pure saving for a run whose output is not combined with other runs', usually lowers the variance of the difference between compared runs, such as an edit and its base, and raises the variance of the mean of replicates. Based on this principle, Copula supports making full use of the cache to reduce computations and allowing the variance of nodes to adapt to the purpose of their running results. Replicated A/B tests reach the precision of independent runs at 0.51-0.59 of the CPU and tokens; prompt optimizers keep held-out quality equivalent at 0.42-0.69 of the task model's GPU cost. Synthetic-data pipeline edits cost 0.39-0.49 of a full rerun's tokens and return 2.8 times sooner; a code-repair agent's edits cost 0.34 of the tokens and 0.39 of the sandbox CPU; no quality loss is significant.