Manuscript Offprint

arXiv:2611.06955

A Sharp Additive Bound for the Threshold Rule in Repeated Rent-or-Buy

Vasco Schiavo

VASCO SCHIAVO

ABSTRACT. Motivated by context management in LLM agents, we study a repeated rent-or-buy model with schedule-independent history growth and a fixed reset price KK, a discrete form of dynamic TCP acknowledgment: every call pays as rent the history accumulated since the last reset, and a reset clears it. The classical threshold rule is 2-competitive, and no deterministic rule guarantees a smaller ratio. We show that, measured additively, its loss is governed by the changes in the growth: if the growth is constant on PP runs, the threshold rule, knowing neither the runs nor the horizon, pays at most (2P−1)K(2P-1)K more than the optimal schedule chosen with hindsight, and the coefficient 2P−12P-1 is sharp. If the growth is only within a factor 1+ε1+\varepsilon of PP runs, the bound holds up to a factor 1+ε1+\varepsilon and an extra εK\varepsilon K. The proof is a potential argument built from the relative value functions of the single-rate problems. On two runs no deterministic rule guarantees a loss below 2K2K. A rule that also resets when the growth decreases guarantees 2K2K, while the threshold rule can lose arbitrarily close to 3K3K.

1. INTRODUCTION

A session makes calls t=1,…,Tt = 1, \ldots, T. At call tt, a schedule observes the history hth_t and decides whether to reset. The call pays hth_t as rent in either case. A reset also costs K>0K > 0 and clears that history. Each call t<Tt < T then appends an increment at≥0a_t \geq 0 for the next call. Neither the increments nor the horizon TT are known in advance. This is a repeated rent-or-buy problem, a finite-horizon discrete variant of dynamic TCP acknowledgment [9,15]. It models an LLM agent, which re-sends its whole history on every call and is billed for it [5, 17, 23], and can summarize the history at a fixed price: when should it summarize? The model assumes that the increments are the same under every schedule, that KK is fixed, and that a reset clears the modeled history and changes nothing the agent does afterwards. A part re-sent by every call, such as the system prompt, is common to all schedules and left out. The model leaves out the effect of a summary on the information the agent keeps and on a prompt cache, and summaries whose size depends on what they summarize. So the theorems bound the modeled cost only.

What is known. The classical threshold rule accumulates the rent paid on non-reset calls since its last reset. It resets when adding the current rent would bring the accumulator to at least KK. It pays at most twice the cost of the best schedule chosen with hindsight, and no deterministic rule guarantees a smaller ratio (Section 2), as in the classical TCP problem [8, Theorems 10 and 12]. For standard dynamic TCP acknowledgment, randomized algorithms achieve ee−1\frac{e}{e-1} [15, Theorem 1]. Our model differs in that terminal history need not be cleared. Under constant growth the rule resets with the period that minimizes the cost per call, a

2020 Mathematics Subject Classification. 68W27, 68W40, 90B05.

Key words and phrases. Online algorithms, rent-or-buy, dynamic TCP acknowledgment, additive guarantees, competitive analysis, context management, LLM agents.

VASCO SCHIAVO

discrete form of Harris's economic order quantity [12]. The factor 2 is a worst case over all sessions, attained by a single burst of growth followed by nothing, with the session ending right after the rule resets. It does not say how the loss depends on the session.

Our result. A run is a maximal block of equal consecutive increments, and PP is the number of runs. We show that the loss of the threshold rule, which does not know the runs, their number or the horizon, is governed by PP alone, whatever the length of the session or the size of the increments.

Theorem 1 (Main Theorem). Let K>0K > 0 and P∈N≥1P \in \mathbb{N}_{\geq 1}.

(1) For every session SS with PP runs, of arbitrary nonnegative rates, the threshold rule satisfies

Crthr(S)≤min⁡{2Cr∗(S),Cr∗(S)+(2P−1)K}.C_{r^{\mathrm{thr}}}(S)\leq \min\bigl\{2C_{r^{*}}(S),C_{r^{*}}(S)+(2P-1)K\bigr\}.

(2) For every η>0\eta > 0 there is a session SS with exactly PP runs such that

Crthr(S)>Cr∗(S)+(2P−1−η)K.C_{r^{\mathrm{thr}}}(S)>C_{r^{*}}(S)+(2P-1-\eta)K.

In words, the threshold rule pays one reset price for not knowing the session and two for each change of growth. The first cannot be improved by any rule (Remark 9), and part (2) shows that the second is sharp. When (2P−1)K<Cr∗(S)(2P-1)K < C_{r^{*}}(S), the bound also improves the ratio 22 to 1+(2P−1)KCr∗(S)1 + \frac{(2P-1)K}{C_{r^{*}}(S)}.

The rule is not new: the commit rule of CADOC, which times context replacement, is of this kind [24]. What is new is the guarantee: a sharp additive bound against the unrestricted optimum, with no predictions or stochastic assumptions, and the best deterministic loss on two runs.

The parameter PP counts exact changes. If every increment is within a factor 1+ε1+\varepsilon of a session with PP runs, the rule pays at most

(1+ε)(Cr∗(S)+(2P−1)K)+εK\left(1+\varepsilon\right)\left(C_{r^{*}}(S)+(2P-1)K\right)+\varepsilon K

by Remark 11.

The proof. The runs cannot be analyzed one at a time: neither the rule nor the optimal schedule restarts at a boundary, and both carry rent across it. We compare the schedules using potentials built from the single-rate problems. Within each run, these potentials bound the excess cost by a telescoping sum. At a change of rate, the old and new potential differences lie in the same interval of width 2K2K, so the change contributes at most 2K2K. The terminal term contributes at most KK, giving K+2(P−1)KK+2(P-1)K.

The rule or the problem? On sessions with at most two runs we can say which part of the loss is the rule's fault. No deterministic rule guarantees a loss below 2K2K (Theorem 16), since none can tell slow growth that goes on from slow growth about to be followed by a burst. The threshold rule loses at most 2K2K when the change is an increase, but arbitrarily close to 3K3K at a decrease, where it keeps paying the stale rent of the fast run. All the sharp sessions of Section 4 change by decreases. A rule that also resets at every decrease loses at most KK per decrease (Theorem 15) and 2K2K on two runs, the best possible (Theorem 18), though it gives up the factor 2: it is not cc-competitive for any constant cc. Table 1 records these results as prices: a rule π\pi has prices (b,d,u)∈[0,∞)3(b,d,u) \in [0,\infty)^3 if every session SS satisfies Crπ(S)≤Cr∗(S)+(b+dP−+uP+)KC_{r^\pi}(S) \leq C_{r^*}(S) + (b+dP_- + uP_+)K, where P−P_- and P+P_+ count the decreases and the increases between consecutive runs. Prices are coefficients of a guarantee for all sessions, not a split of the loss on one. Whether some rule pays KK for every change, on any number of runs, is open.

TABLE 1. Prices (b,d,u)(b,d,u) in units of KK. Larger triples are prices too. The first two rows fix the least base, b=1b=1, and give the dd and uu we prove with it and the known lower bounds. The last row gives limits for every rule. On sessions with two runs, u=1u=1 suffices for both rules, and no rule with b=1b=1 has a smaller uu (Theorems 16 and 18).

base bbdecrease ddincrease uu
threshold rule12, sharp (Sec. 4)between 1 and 2
drop-aware rule1at most 1 (Thm. 15)between 1 and 2
every ruleat least 1 (Rem. 9)openb+u≥2b+u \geq 2 (Thm. 16)

Related work. Beyond the worst case, guarantees exist for predicted resets [2,6,14,20], for general delay costs [7], for stationary stochastic arrivals up to constant factors [18, Section 3], and against the best of kk online experts: Harada, Kawase and Sumita [11] give a (2+ε)(2+\varepsilon)-competitive randomized rule with expected regret O(OPTlog⁡(k+1)+log⁡(1ε))O(\sqrt{\mathrm{OPT}\log(k+1)}+\log(\frac{1}{\varepsilon})) against the best of them, in the tension between ratio and regret studied by Andrew et al. [1]. Closest in spirit is tracking regret, which grows with the number of switches of the comparator [13]. Here, the changes are in the input instead, and the comparator is the unrestricted optimum. Worst-case analyses of lot-sizing heuristics bound ratios to the optimum [3,21], which no heuristic that ignores future demand brings below 2 [4,22]. Vachani refines them by the horizon and for constant or bounded demand. These are ratios, and none of them depends on the number of changes in the demand. For agents, CADOC batches context replacements with a stationary-optimal batch size and a commit rule that is 2-competitive for its waiting-plus-setup cost when the setup cost is a positive constant [24, Propositions 1 and 2]. Other compaction timings are tuned or learned [10,19,25]. Section 2 sets up the model, Sections 3 and 4 prove Theorem 1, and Section 5 compares rules.

Disclosure. A large language model was used to help prepare this paper. The author has read and checked every result and takes full responsibility for the paper, including any errors.

References (24)