Manuscript Offprint
arXiv:2610.22781Anytime Contracts for AI Services
Abstract
AI services are prone to moral hazard, as model providers can silently route requests to cheaper, lower-quality models, and the inherent stochasticity of model outputs makes this degradation hard to detect. Contract theory addresses moral hazard by designing payment rules that reward high-quality outputs and prevent strategic overcharging. However, existing frameworks assume interactions of fixed duration, whereas AI services are typically consumed through subscriptions and pay-as-you-go APIs that users can terminate at any time based on observed performance. We show that this flexibility can break standard contracts, opening them up to abuse by either the providers or users. To address this, we extend contract theory to account for unknown exit rules. We formalize the problem as a Principal-Agent game, and show that budget-optimal contracts in this setting are proportional to anytime-valid hypothesis tests based on likelihood-ratio e-values. We give an efficient algorithm for computing anytime contracts and show how betting e-processes can be used to approximate them when the models are unknown. Finally, we evaluate our findings on synthetic data and data from deployed LLMs.
1 INTRODUCTION
AI systems are becoming ubiquitous and increasingly embedded in high-stakes decision-making across domains. Such decisions often require the intricate reasoning abilities of high-quality models, which most organizations cannot train and operate in-house, leading them to delegate AI tasks to external service providers. Due to their generality, AI systems are increasingly viewed as tools, used for indefinite durations within organizational processes. Accordingly, payment for such services typically takes the form of auto-renewing contracts or pay-as-you-go APIs, which are arrangements without a predetermined end.
Together with growing demand, the increasing costs of high-quality models create economic risks. Both model inference and the evaluation of generative-model outputs are inherently noisy, while the process by which providers route queries to different models is typically opaque. This creates information asymmetry between AI service providers and their users wherein an end-user cannot tell whether a low quality outcome is the result of randomness or deliberate degradation from the service provider. Since higher-quality models are generally more costly to operate, profit-maximizing providers can benefit from routing requests to cheaper, lower-quality models. This gives rise to moral hazard [24, 3, 27]. We note that incidents of quality degradation are well-documented in practice [4, 11], and it's not hard to believe that fully strategic providers will leverage such gaps to their advantage.
Moral hazard is a classic problem in economics, commonly addressed by designing pay-for-performance payment rules, encoded as contracts, which reward the agent for quality signals that indicate effort [15, 12, 7]. Recent work has started applying these ideas in settings native to machine learning [24, 25], designing payment schemes that implicitly assume fixed-duration interactions. However, when AI services are used on an ongoing basis, contractual interactions become inherently dynamic. Payment schemes used in practice either have an indefinite duration by design (e.g., APIs) or contain an exit clause that can be triggered at any time by either party, potentially mandated by regulators [8]. For example, one may want to cancel a subscription or switch to a different provider. In such settings, routing decisions interact with concerns about contract duration, an interplay which may cause fixed-duration contracts to achieve an opposite goal from the one they target.
- Equal contribution.
To illustrate this, consider a setting in which, at each step, a strategic provider receives a task from a client organization and routes it to either a costly high-quality model or a cheaper low-quality one, then each task either succeeds or fails. In the fixed-duration setting, the optimal contract incentivizing high effort for the minimal expected pay is the one that pays a large amount only if all tasks are successful (e.g., [6, 2]). Such contracts fail to incentivize high effort in our setting: if the client terminates after the first failure, payment is always zero at termination, so a provider anticipating such behavior has no incentive to bear the cost of the higher-quality model and therefore only offers lower-quality outputs.
Alternatively, another common approach is to pay per successful task. However, if the client only cares about completing a task and terminates once it succeeds—for example, when trying to prove a major mathematical theorem—the provider receives exactly one payment regardless of duration. Hence, when a substantially cheaper model has some chance of success, the provider may therefore prefer to route prompts to it instead.
Both examples show that exit clauses can create economic failures under different stopping criteria. Since the rules governing whether interaction continues or terminates are varied and typically unknown in advance, there is a need for tools that explicitly account for these dynamics and their uncertainty.
Contributions: In this work, we develop a theory of contract design for AI services that explicitly accounts for the dynamic nature of the problem and—crucially—the exit clauses that are key features of AI services. Our contributions are as follows.
• Contracts under stopping time uncertainty: We formalize the interaction as a Principal-Agent game in which the provider deploys a potentially adaptive model-routing policy, quality is measured at each step, and the user may choose to terminate the contract according to any—possibly data-dependent—stopping rule in a prescribed class T. We show that accounting for exit clauses can cause existing contract-theory approaches to fail, motivating the need for contracts that explicitly deal with stopping time uncertainty. In the resulting formulation, we require that the provider prefers providing the high-quality policy over their alternative uniformly over all stopping rules a user could choose. This reflects the fact that a user's stopping rule is typically private and could be arbitrary. The resulting formulation is a strict generalization of existing fixed-duration contract design problems in machine learning which implicitly consider the case where the class of admissible stopping rules is a singleton.
• Anytime contracts: Our central result characterizes minimum-budget contracts robust to stopping-time uncertainty. The optimal contract takes the form of a scaled sequential likelihood-ratio test on the sequence of observed quality signals, with the required budget increasing when the target policy is more costly or harder to distinguish statistically. The resulting likelihood-ratio processes are also log-optimal e-processes [13, 21], extending the connection between statistical testing and contract design [23, 24] to anytime-valid inference [26, 22]. For bounded stopping time families, we also show that these contracts can be computed efficiently by reducing to an optimal stopping problem.
• Audits with partial information. Implementing the optimal anytime contract requires knowledge of the output distributions induced by the provider's routing policies. Using a standard e-value construction [28], we develop an approximation to the optimal contract that can be implemented from observed signals alone, provides anytime service-level guarantees, and can sometimes recover the optimal anytime contract exactly.
• Empirical validation under realistic conditions: We present empirical validation of our theory both in a simple synthetic environment and with real data from closed-source LLMs. Synthetic experiments illustrate how stopping-time uncertainty changes optimal payments and worst-case stopping behavior. Experiments using the Holistic Agent Leaderboard [18] examine robustness costs, partial distributional information, and demonstrate how contracts can deter multiple alternative policies.
Statistical contracts. Saig et al. [23, 24] establish a correspondence between optimal contracts and optimal statistical tests for delegated learning and text generation. Their formulations assume a fixed duration, while we study how the design problem changes when the contract is allowed to terminate at an observation-dependent stopping time. Bates et al. [1] connect e-values to optimal menus in statistical testing settings with adverse selection, where the provider's type is uncertain. In contrast, we consider general moral hazard settings, in which the provider's type is known but their action is hidden, and show that likelihood-ratio e-processes arise as optimal contracts.
Dynamic contracting. Within the broader moral hazard literature, our work contributes to the study of dynamic contracting, where contractual relationships have a temporal component possibly evolving over time (e.g., [16, 10, 5]). Our formulation is close in spirit to that of Ezra et al. [9], who study contracts with sequential actions and stopping criteria strategically set by the agent. In contrast, our setting assumes that the stopping rule is chosen adversarially, and incentive compatibility must hold uniformly over an admissible class of stopping times.
2 PROBLEM SETTING
We formalize our setting as a Principal-Agent game, extending the classic contract design framework to accommodate stopping-time uncertainty. Our setting is illustrated in Figure 1.
The game consists of two players: a client organization (Principal) who seeks access to AI services and has bargaining power to offer performance-based pay, and a provider (Agent) who operates a set of generative models at varying levels of quality and cost. Interaction takes place over discrete steps : at each step, the client sends one or more prompts and receives a response y for each. Importantly, we make no assumption on the amount or frequency of data collected at each step. A step may correspond to a single query, a batch of interactions aggregated over a month, or any other, potentially irregular, unit of observation. Interaction may terminate after each step based on the observed quality of outputs up to that step. Our goal is to design an anytime payment scheme which incentivizes the provider to invest effort despite this uncertainty.
To generate responses, the provider operates a set of generative models, denoted by . Each model is a mapping from a prompt to a response . We assume that each call to a model has expected cost . For each prompt, the model generating the response is picked by a router , which maps prompts to generators, possibly at random and adaptively based on past performance. The client organization seeks generated responses from a high-quality routing policy , rather than a low-quality routing policy . We study the two-action setting — a provider makes a decision which of the two routers to deploy. Empirically, we observe that our contracts can sometimes deter a much larger class of actions.
Moral hazard in AI services. Routing decisions are made internally by the provider, and the client only observes the resulting prompt-response pairs. Without monetary compensation, this information gap creates an economic failure known as moral hazard, as the provider can reduce costs by always using the low-cost routing policy internally. More formally, denote by the hidden sequence of generative models used up to time , and note that is random and depends on the choice of . The cumulative cost of generating responses using these models is . When high-effort routing is more costly , and without additional compensation, a strategic provider knowing that contractual relations will terminate at time will deploy . We note that the expectation integrates over both the decisions made by the router and the randomness over prompts.
Pay for performance. To incentivize high-effort routing, the client commits to pay the provider based on measured performance. Formally, we assume the existence of a quality evaluation function, denoted by q, which maps a prompt-response pair to a quality signal . We denote the space of signals by S and the signal observed at time t by . The client commits to a contract which compensates the provider by transferring monetary units upon termination, where is the observed signal history. The assumption of payment at contract termination is made for simplicity, and we note that other schedules such as monthly or per-use payment can be implemented via discounting and refund mechanisms.
Given contract , the provider's utility when relations terminate at time t after deploying models and observing signals is thus:
Given knowledge of termination at time and now with commitment to receive compensation, the provider will deploy if . Extending standard contract design, we consider contracts that contain an exit criterion, allowing contractual relations to be terminated after any step and for any reason. Formally, let be a subset of the set of
respect to augmented by additional private randomization.
Formally, the routing decision is measurable with

Figure 1: Contracts with stopping rule uncertainty as a Principal-Agent game (Section 2).
integrable stopping times with respect to both , , for the filtration . For example, a stopping rule could terminate the contract after observing low-quality outputs, or after steps. Particularly notable instances are stopping times with uniformly bounded mean under both laws, and stopping times uniformly bounded by , which we denote by . For a general stopping rule , termination time itself becomes a random variable, and the expected utility of the provider given and payment rule is:
In the following section, we show that incorporating exit clauses into contracts invalidates many of the existing approaches to contract design, which in turn motivates our construction of anytime contracts.
3 IMPLICATIONS OF STOPPING
In this section we show that moving from a fixed contract duration, as in the classic setting, to an uncertain one has significant implications even when the underlying process is relatively simple. In particular, we analyze contractual settings induced by independent Bernoulli processes, in which quality signals are pass/fail, independent, and identically distributed – capturing settings where outputs are considered sufficiently good if they meet a threshold. We present natural extensions of fixed-duration contract theory to indefinite durations, and show that they fail to incentivize once the contract can be adversarially terminated based on past performance.
To begin, consider a setting in which the provider operates two models, denoted by , and the client seeks outputs generated by H. Serving model H costs per step and returns a passing output with probability ; model L costs per step and passes with probability . We assume and , so that the model requested by the client has both higher quality and higher cost. The high-quality router always serves the high-quality model H and the deviation always serves the low-quality one. Signals are therefore i.i.d. under , and i.i.d. under .
We now present two families of practically-motivated contracts, and analyze them from this perspective:
Failures of repeated optimal single-step contracts. A first attempt at designing contracts would be to simply repeatedly implement an optimal single-step contract. Such contracts typically pay out as a function of performance, for example by paying per high-quality output. Formally, consider for some . We note that such contracts are step-wise optimal, as optimal single-step contracts for Bernoulli outcomes only pay on success (e.g., Saig et al. [24], Prop. 3). We show that for all contracts of this type, if the ratio of success rates is smaller than the ratio of costs, under the stopping rule which represents clients that stop after a task is completed, the provider has higher utility if a low-quality model is deployed.
Proposition 1 In Bernoulli contractual settings with and any step-wise contract, the provider benefits from using a low-quality policy under .
Proof in Appendix A.2. We note that the conditions are often met in current practical settings. For example, in the datasets we analyze in Section 6.2, in particular Holistic Agent Leaderboard [HAL; 18], taking Claude Opus 4.1 as a “high” model and Claude-3.7 Sonnet as a “low” one yields and . Moreover, this condition is met in any setting where the alternative model L has negligible cost .
Failures of optimal fixed-duration contracts. Another naive approach would be to design an optimal contract for a fixed duration. As we show, this approach also fails under a simple stopping rule. For Bernoulli outcomes and a fixed duration T, the number of successful evaluations up to termination is a Binomial variable, and the fixed-duration contract minimizing expected pay is the all-success rule with a suitable
Formally, a stopping rule is a function from observed sequences to scalars, such that if and only if stops the process at time after observing signals .
(e.g., Dütting et al. [6], Lemma 7). We extend this to any duration by taking at whatever time the contract ends, and possibly tuning for any . We show that under this family of contracts, the provider prefers when , which represents clients that switch to a different provider after a failure:
Proposition 2 For any Bernoulli contractual setting and all-success pay, the provider benefits from using the low-quality policy under .
Proof in Appendix A.3. Intuitively, by construction there is one failure at stopping, and therefore all-success payment is always zero, and the provider has incentive to deploy due to lower operational costs.
Together, these examples indicate that a more suitable framework for this setting is required. Furthermore, we note that examples of stopping times that break incentive compatibility for simple contracts also exist for bounded stopping times – See Appendix A.4.
4 ANYTIME CONTRACTS
Our results in the previous section highlight the need for accounting for stopping-time uncertainty in contract design. Since the stopping rule is in general private for the client organization and thus unknown to the provider, we study the problem of designing contracts that are robust to choices of stopping rules. As we show, this property gives rise to a new class of anytime contracts which have natural connections with anytime-valid statistical tests.
Contracts with stopping-time robustness. In settings with stopping time uncertainty, the goal of the client organization is to design an efficient payment rule incentivizing the deployment of the high-effort routing policy under any choice of stopping rule . Formally, associating economic efficiency with required budget — defined as the maximum theoretical transfer — contract design solves the following optimization problem:
Consistent with contract design nomenclature, we refer to the constraints of Eq. (3) as incentive compatibility constraints. When a contract w satisfies these constraints, we say that it is an anytime contract that implements .
Our characterization has a natural formulation in terms of distributions over stopped sequences , which we now formally define. Denote by a version of the conditional distribution of the quality signal given the history up to that time. We assume absolute continuity for every , and every history reachable under , so that the Radon-Nikodym derivative is well-defined, and we can therefore denote the likelihood ratio by . For a stopping rule , denote by the probability of observing sequence when the contract terminates according to . We note that is defined over the set of nonempty signal sequences .
Budget-optimal anytime contracts. Using the notations defined above, Eq. (3) can be formulated as a linear program, in a possibly infinite-dimensional space and with an infinite number of constraints (see Appendix B.1). The linear program is finite when S is finite and stopping times are bounded, however we also note that even in the simple case of Bernoulli processes (defined in Section 3) and bounded stopping times , the number of variables is exponential in T, and the number of constraints is doubly-exponential in T. Thus, direct naive optimization is computationally infeasible for all but very small signal spaces and values of T, further motivating the search for structure. Our main result characterizes the solution of Eq. (3) in the general case.
Theorem 1 A budget-optimal contract implementing under stopping-time uncertainty T is:
with required budget given by:
where is the likelihood ratio at termination, is the utility of the provider without any compensation under policy , is the total variation distance, and is the positive part.
Proof in Appendix B.2. The proof gives a direct measure-theoretic characterization of minimum-budget contracts that avoids the linear-program duality used in prior finite-horizon results [23, Thm. 1], allowing generalizations to settings with unbounded integrable stochastic stopping and possibly infinite signal spaces. In addition, we note that the generalized
The assumption of absolute-continuity is made for convenience. If it fails, there are events that occur under but not under ; on such events the deviation is identified with certainty, so it is optimal to set the payment to zero. The remaining part of the problem is then treated on the absolutely continuous component.
min-budget characterization in our proof also expands the characterization frontier in non-robust settings, and may be of independent interest.
Statistical interpretation. The threshold rule in the optimal contract, , also appears naturally in hypothesis testing. More generally, the likelihood-ratio test between and accepts the null when . When the test may be evaluated at an arbitrary stopping time, is a nonnegative martingale under , hence an e-process, and the resulting test is anytime-valid. Likelihood-ratio e-processes are also optimal under log-growth criteria in sequential testing [21, Sec. 3.5]. Thus the same likelihood-ratio statistic arises from two different optimality criteria: growth in anytime-valid testing and budget in our contract design problem. The parameter controls how protective the audit is for the provider. Ville's inequality gives for every . Thus a provider deploying is denied payment with probability at most , uniformly over stopping rules. The budget-optimal contract corresponds to the strictest threshold of .
4.1 Computing Anytime Contracts
We now compute the contract of Theorem 1 in the setting where and a finite signal space . The optimal budget is a supremum over stopping times, of which there are doubly exponentially many in , hence a naive enumeration does not work. However, extracting a worst-case stopping rule for a candidate budget is a dynamic programming problem. Finding a minimal such budget then reduces to a finiteness check and a binary search over the budget parameter.
For a history and , denote and , and let the stopping reward be . Dynamic programming applies because of the structure of stopping rules: at every history, a stopping rule either stops and collects the reward , or continues to the next signal, where it faces the same choice [20]. Therefore satisfies the Bellman recursion:
with for . A single backward pass over the tree of reachable histories, whose size we denote by , computes , the largest incentive violation of over . We call this pass VERIFY( ), so that is incentive compatible exactly when VERIFY( ) 0. Since VERIFY( ) is nonincreasing in , the minimal budget is found by binary search after a finiteness check. The following theorem formalizes this approach, details are in Appendix C.2:
Theorem 2 (Correctness and complexity)
Given a history representation of size n, VERIFY(B) computes the largest incentive violation in arithmetic operations and oracle calls. Finiteness of can also be checked in operations. If , the resulting search returns an incentive-compatible satisfying using arithmetic operations and oracle calls.
The full history tree has nodes. However, since depends on only through , whenever , and depend on only through its signal counts, histories with equal counts can be merged, giving and computation polynomial in . For i.i.d. Bernoulli setting of Section 3, this is .
5 PARTIAL PRIOR KNOWLEDGE
The optimal contract of Section 4 has a simple form, but it may be difficult to implement due to the fact that its audit mechanism—captured in the condition —requires knowledge of the likelihood ratio , and hence knowledge of the distributions of the signals induced by both routing policies. In most settings, the client organization or third-party evaluator lacks direct knowledge of the underlying models and only observes the provider's evaluation history. In this section, we construct a principled audit directly from the observed signal history; so that the provider's performance can be audited without the auditor's knowledge of the underlying models.
We assume that the signal space consists of bounded scalar evaluations , and construct the audit using the testing-by-betting framework of Waudby-Smith and Ramdas [28]. The resulting contract inherits statistical properties: If the provider commits to maintaining a reference quality level , the same audit gives an anytime-valid level- guarantee against denial of payment. Moreover, when the mean quality of is , every audit in the constructed family is exactly a likelihood-ratio audit against an associated alternative signal law.
To construct the audit, fix a reference level , and initialize . Before observing the auditor chooses a nonnegative stake , which may depend on the previous signals but not on , and updates . We require , ensuring that the process remains nonnegative. The interpretation is that accumulates evidence against performance at the reference level: it increases when and decreases when . For ,

Figure 2: Anytime contracts for synthetic Bernoulli processes (Section 6.1). (Left) Optimal anytime contracts under different objectives. (Center) Non-monotone deterred set. (Right) Worst-case stopping rule.
we define the audit and the corresponding contract . Once and the stake rule are specified, the audit can be evaluated sequentially from the observed signals alone.
Service-level protection. Suppose the provider guarantees service level at every reachable history. Because is chosen before , , so is a nonnegative supermartingale. Ville's inequality therefore implies . Thus a provider satisfying the advertised service level receives level- protection against denial of payment, uniformly over when the contract is stopped – See Appendix D.1.
Relation to the likelihood-ratio audit. Suppose now that the promised router lies exactly on the service-level boundary, . For any admissible predictable stake , define an associated conditional signal law by . The conditional-mean identity ensures that this is a probability kernel. Its one-step likelihood ratio relative to the promised law is exactly , and therefore its running likelihood ratio is .
Finally, we note that an analogous algorithmic approach as described in Section 4.1 can be used to find the minimal budget that makes incentive compatible in the class and assuming a finite signal space . We relegate the details to the Appendix D.3.
6 EMPIRICAL EVALUATION
In this section, we develop intuition about anytime contracts and evaluate them in empirical settings. Throughout, the evaluation signal is Bernoulli, as described in Section 3. Exit times are uniformly bounded, costs are per step, and we use the algorithm presented in Section 4.1 for computation. Constants and implementation details are given in Appendix E.
6.1 Qualitative Analysis
We begin by qualitatively analyzing the structure imposed by optimal contracts on synthetic examples. We do so by comparing min-budget and min-pay, investigating the set of routers a contract deters, and visualizing worst-case stopping rules.
Min-budget and min-pay. Figure 2 (Left) compares the min-budget and worst-case min-pay objectives in a Bernoulli instance. The min-pay optimum, obtained via solving the linear program in Appendix B.1, has a qualitatively different structure from the min-budget one, with payments unequal across histories. This contrasts the fixed-duration setting, where contracts optimal under both objectives can be expressed as scaled statistical tests [24, Thm. 1], indicating that a foundational discrepancy between the two objectives arises from adversarial stopping robustness.
Deterred set. A contract designed to incentivize one router against another may deter others too, but not all of them. For Bernoulli signals, we design a contract incentivizing against , and measure incentive compatibility for other success-cost pairs . Figure 2 (Center) outlines the results. We observe that the boundary is not monotone in , so incentive compatibility against does not guarantee deterrence of a policy that is both less accurate and more expensive. This contrasts fixed-duration settings, where success counts are Binomial, and such monotonicity holds due to their monotone likelihood ratio property (e.g., by [19, Lem. 3.4.2]).
Worst-case exit rules. Figure 2 (Right) displays the worst-case exit rule returned by the dynamic programming algorithm of Section 4.1. The organization stops where the likelihood ratio leaves the audit's verdict the closest to the threshold of 1. As a possible interpretation, when the ratio is small or large the verdict is already anticipated, so the worst case stopping

Figure 3: Empirical contracts based on the HAL dataset (Section 6.2). (Left) Robustness markup and probability of no monetary transfer, for varying significance levels and horizons. (Center) Betting e-value contracts from first-moment information. (Right) Deterring a family of alternative models with a two-action contract.
rule keeps consuming to drain the provider's profit.
6.2 Practical Considerations
We now calibrate the same objects on deployed models, using empirical data from the Holistic Agent Leaderboard [HAL; 18] to set p, q, and . Accuracies and costs are the SWE-Agent entries of the SWE-bench Verified Mini leaderboard [14], a 50-task subset of the SWE-bench Verified benchmark [17]. We evaluate three economic quantities: the role of in guaranteeing providers are paid more often, the price of not knowing the observation laws, and whether a single contract can deter an entire family of models.
The role of . Figure 3 (Left) traces the implementable range for Claude Opus 4.1 over Claude-3.7 Sonnet. The vertical axis is the price of robustness , the budget measured against the one that would suffice if the exit date were known to be T; the horizontal axis is the worst-case probability that an honest provider is denied payment. Lowering raises the cutoff , so the audit pays on more histories: the price rises and the denial probability falls. The knob is thus a dial for favoring the provider, priced accordingly. Smaller values of need a larger markup as the additional slack given to the provider increases information gaps. Larger T lifts every arc, since a longer duration supplies more exit rules to choose from and the supremum runs over a larger class.
The price of partial information. Keeping the same pair, Figure 3 (Center) reports the wage of the betting audit of Section 5 relative to the full-information min-budget contract of Theorem 1, as a function of the stake , and with the announced service level set to . At the betting process recovers the likelihood ratio as discussed in Section 5, achieving a global minimum markup of 1. The approximation is forgiving near , allowing for near optimal audits even with partial information.
Deterring a family of models. Finally, we revisit the deterred set with empirical data. Figure 3 (Right) outlines the deterrence set for the Claude family of models, induced by a contract targeting Sonnet 4.5H, the highest-performing model in the family appearing in the leaderboard, against Sonnet 3.7H as the reference alternative. Despite being designed against a single reference model, the contract incentivizes the target model over every alternative Claude model appearing on the leaderboard, even though the resulting deterrence set is neither monotone nor convex.
7 CONCLUSION & LIMITATIONS
In this work, we introduce a contract-theoretic framework that explicitly accounts for stopping-time uncertainty and addresses the moral hazard problem inherent in AI services. We show that several natural constructions from the fixed-horizon setting fail under this stronger requirement, and characterize a budget-optimal contract that remains incentive compatible across admissible stopping rules. The resulting contract is efficiently computable via dynamic programming, enabling empirical analysis on both synthetic instances and data from deployed models.
Our framework also relies on several assumptions that motivate further inquiry. In particular, we assume that the client has sufficient bargaining power, or can coordinate with others to exercise such power; model the principal–agent interaction in isolation from other market forces; assume that clients are likely to exercise the most adversarial stopping rule in T; and require stopping rules to be integrable. Relaxing these assumptions raises intriguing questions for future work.
Acknowledgements
Eden Saig is supported in part by the Zuckerman STEM Leadership Program, and by the AISI Alignment Project.
AI Use Statement
In this work, we used generative AI tools to assist in proving our theoretical results, to help formulate the linear-programming formulation in Appendix B.1, to generate code implementing our methods and experiments, and to obtain feedback on drafts of the paper, including on the research methodology and experiments. We have not used generative AI tools to formalize the problem, to develop research ideas or hypotheses, or to interpret our results. Generating or cleaning data sets, translation, and qualitative data analysis are not applicable to this work. Additionally, we used generative AI tools to identify relevant literature, to format references, and to improve the grammar, flow, and readability of the text and the typesetting of mathematical formulas; no sections of the paper were drafted by generative AI tools.
We have reviewed all AI-assisted work: all AI-assisted proofs and derivations were checked line by line by the authors; all AI-generated code was read and reviewed by the authors and tested on independent small-scale instances, where we verified that independent solvers return the same solutions; all suggested references were verified against the original sources; and all AI-edited text was read and revised by the authors. We take responsibility for the final content of this work, including text, claims, or artifacts produced with the aid of generative AI.
References
[1] Stephen Bates, Michael I. Jordan, Michael Sklar, and Jake A. Soloff. Principal-agent hypothesis testing. Journal of the American Statistical Association, 0(to appear):1–38, 2026.
[2] Philip Bond and Armando Gomes. Multitask principal-agent problems: Optimal contracts, fragility, and effort misallocation. Journal of Economic Theory, 144(1):175–211, 2009.
[3] Will Cai, Tianneng Shi, Xuandong Zhao, and Dawn Song. Are you getting what you pay for? Auditing model substitution in LLM APIs. arXiv preprint arXiv:2504.04715, 2025. NeurIPS 2025 Workshop on Regulatable ML.
[4] Lingjiao Chen, Matei Zaharia, and James Zou. How is ChatGPT's behavior changing over time? Harvard Data Science Review, 2024. doi: 10.1162/99608f92.5317da47.
[5] Jakša Cvitanić and Jianfeng Zhang. Contract theory in continuous-time models. Springer Science & Business Media, 2012.
[6] Paul Dütting, Tim Roughgarden, and Inbal Talgam-Cohen. Simple versus optimal contracts. In Proceedings of the 2019 ACM Conference on Economics and Computation, pages 369–387, 2019.
[7] Paul Dütting, Michal Feldman, and Inbal Talgam-Cohen. Algorithmic contract theory: A survey. Foundations and Trends® in Theoretical Computer Science, 16(3-4):211–411, 2024.
[8] European Parliament and Council of the European Union. Directive 2011/83/EU on consumer rights. Official Journal of the European Union, L 304/64, 2011. Article 9, Right of Withdrawal.
[9] Tomer Ezra, Michal Feldman, and Maya Schlesinger. Contract design for sequential actions. In Proceedings of the 2026 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 6537–6570. SIAM, 2026. doi:10.1137/1.9781611978971.234.
[10] Drew Fudenberg, Bengt Holmstrom, and Paul Milgrom. Short-term contracts and long-term agency relationships. Journal of Economic Theory, 51(1):1–31, 1990.
[11] Irena Gao, Percy Liang, and Carlos Guestrin. Model equality testing: Which model is this API serving? In International Conference on Learning Representations (ICLR), 2025.
[12] Sanford J. Grossman and Oliver D. Hart. An analysis of the principal-agent problem. Econometrica, 1983.
[13] Peter Grünwald, Rianne de Heide, and Wouter Koolen. Safe testing. Journal of the Royal Statistical Society Series B: Statistical Methodology, 2024. doi: 10.1093/jrsssb/qkae011.
[14] Holistic Agent Leaderboard. HAL: SWE-bench verified mini leaderboard. https://hal.cs.pinceton.edu/swebench_verified_mini, 2026. Accessed 2026-10-4.
[15] Bengt Holmström. Moral hazard and observability. The Bell Journal of Economics, 1979.
[16] Bengt Holmstrom and Paul Milgrom. Aggregation and linearity in the provision of intertemporal incentives. Econometrica: Journal of the Econometric Society, pages 303–328, 1987.
[17] Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao, Kexin Pei, Ofir Press, and Karthik Narasimhan. SWE-bench: Can language models resolve real-world GitHub issues? In Inter-national Conference on Learning Representations (ICLR), 2024.
[18] Sayash Kapoor, Benedikt Stroebl, Peter Kirgis, Nitya Nadgir, Zachary S. Siegel, Boyi Wei, Tianci Xue, Ziru Chen, Felix Chen, Saiteja Uttpala, Franck Ndzomga, Dheeraj Oruganty, Sophie Luskin, Kangheng Liu, Botao Yu, Amit Arora, Dongyoon Hahm, Harsh Trivedi, Huan Sun, Juyong Lee, Tengjun Jin, Yifan Mai, Yifei Zhou, Yuxuan Zhu, Rishi Bommasani, Daniel Kang, Dawn Song, Peter Henderson, Yu Su, Percy Liang, and Arvind Narayanan. Holistic agent leaderboard: The missing infrastructure for AI agent evaluation. In International Conference on Learning Representations (ICLR), 2026. arXiv:2510.11977.
[19] Erich Leo Lehmann and Joseph P Romano. Testing statistical hypotheses. Springer, 2005.
[20] Goran Peskir and Albert Shiryaev. Optimal Stopping and Free-Boundary Problems. Lectures in Mathematics. ETH Zürich. Birkhäuser, Basel, 2006. doi: 10.1007/978-3-7643-7390-0.
[21] Aaditya Ramdas and Ruodu Wang. Hypothesis testing with e-values. Foundations and Trends® in Statistics, 1(1-2):1–390, 2025.
[22] Aaditya Ramdas, Peter Grünwald, Vladimir Vovk, and Glenn Shafer. Game-theoretic statistics and safe anytime-valid inference. Statistical Science, 2023.
[23] Eden Saig, Inbal Talgam-Cohen, and Nir Rosenfeld. Delegated classification. Advances in Neural Information Processing Systems, 36:13200–13236, 2023.
[24] Eden Saig, Ohad Einav, and Inbal Talgam-Cohen. Incentivizing quality text generation via statistical contracts. Advances in Neural Information Processing Systems, 37:51196–51222, 2024.
[25] Eden Saig, Tamar Garbuz, Ariel D. Procaccia, Inbal Talgam-Cohen, and Jamie Tucker-Foltz. Adaptive contracts for cost-effective AI delegation. In International Conference on Machine Learning (ICML), 2026.
[26] Glenn Shafer. Testing by betting: A strategy for statistical and scientific communication. Journal of the Royal Statistical Society: Series A, 2021.
[27] Ander Artola Velasco, Stratis Tsirtsis, Nastaran Okati, and Manuel Gomez-Rodriguez. Is your LLM overcharging you? Tokenization, transparency, and incentives. In International Conference on Machine Learning (ICML), 2026.
[28] Ian Waudby-Smith and Aaditya Ramdas. Estimating means of bounded random variables by
betting. Journal of the Royal Statistical Society Series B: Statistical Methodology, 86(1), 2024. doi: 10.1093/jrsssb/qkad009.
Anytime Contracts for AI Services: Supplementary Materials
A IMPLICATIONS OF STOPPING
A.1 Payments depending only on time
In this family of contracts, the client's payment is only dependent on time; formally for some increasing function , e.g. fixed payment per step . Assuming that a deterministic stopping time is in , we immediately obtain that the contract will not be incentive compatible for that . Formally, the provider utility is , and as we obtain . Hence the low-quality policy is always beneficial for the provider in such cases.
A.2 Step-wise pay-for-performance
By construction and , so the running count of successes equals one on every path, and almost surely under both routers. Hence the utilities are:
Stopping time satisfies if and only if . Somewhat surprisingly, even for arbitrarily large , the contract may fail to be incentive compatible, as the constraint for is wage-agnostic.
A.3 Optimal fixed-horizon contracts
By construction , therefore . The utilities therefore are
as it always holds that .
A.4 Failure of incentive compatibility in
The exit rules of Section 3 are unbounded. Restricting to does not help. We now give such an instance.
Take , , , , and the contract with , so that and . Note that this is the closed-form solution that is min-pay optimal [6]. Therefore, the contract is incentive-compatible at each deterministic . Now let the client leave on a success and otherwise run to the bound,
a stopping time bounded by , hence in . A straightforward calculation gives us the utilities for “high” and “low” models, respectively: , so the deviation is strictly better off for every .
B ANYTIME CONTRACTS
B.1 Linear Programming Formulations
Since , incentive compatibility at is linear in :
Introducing epigraph variables for the objectives, the min-budget and min-pay problems are the linear programs
s.t.
s.t.
over measurable . Both programs have one constraint per stopping rule, and are infinite-dimensional when is infinite or is unbounded.
Finite case. Suppose is finite and , and let ; payments on histories longer than are irrelevant. For , define
For adaptive routers, and are products of the conditional signal probabilities along . Identify each with its stopping set , the set of histories at which it stops, so that every history in has exactly one prefix in . Then and coincide with and on , and Eq. (7) becomes
while the min-pay constraint becomes . Both programs thus have variables. The number of stopping sets is , where and , which grows doubly exponentially in whenever .
B.2 Proof of Theorem 1
In Eq. 5, we interpret as 0 when and as when , and take . The contract in Eq. 4 is understood for ; when , the assertion is that no finite-budget contract implements . Note that for any nonnegative -measurable function , by the definition of the likelihood ratio as the Radon–Nikodym derivative, we have
where the expectation is taken over the induced distribution of signals by .
As is an integrable stopping time with respect to both , it is almost surely finite, and the following decomposition holds -almost surely:
Now note that is a -measurable function, as is a stopping time for this filtration.
Therefore, utilizing Tonelli's theorem and nonnegativity of :
Since this identity holds for every nonnegative measurable function of the stopped signal sequence, is the Radon–Nikodym derivative of with respect to .
Fix arbitrary and an incentive-compatible with finite budget . In particular, for each ,
Moreover, since is finite and is integrable under both routers,
Thus both expected payments and both expected costs are finite, which justifies the subsequent rearrangements of the incentive compatibility constraint.
Note that
so this is simply a compact way of referring to the cost differential. Therefore, unpacking the incentive compatibility constraint for , we obtain that it is equivalent to
Consequently, using the change of measure and linearity of expectation, the constraint is equivalent to
Next, note that the following inequality holds pointwise:
Taking expectations of both sides, we obtain
where the last equality is the total variation identity for two probability measures and their Radon–Nikodym derivative. Combining with incentive compatibility, we obtain
If the total variation is zero and the cost differential is positive, we obtain using our conventions, and this inequality rules out every finite-budget contract. Otherwise, using nonnegativity of the budget and the convention above, we obtain
Taking the supremum over all , we achieve the lower bound
Suppose now that . It remains to show that this budget is achieved. Define
For every , we have
The penultimate inequality follows from the definition of when the total variation is positive. When it is zero, finiteness of forces the cost differential to be nonpositive, so the inequality still holds.
Thus satisfies incentive compatibility for every . Its budget is at most , and the lower bound above shows that it is budget-optimal with budget exactly .
C COMPUTING CONTRACTS
C.1 Algorithm pseudocode
Please consult Algorithm 1.
Algorithm 1 Computing a likelihood-ratio contract
Input: Duration T and reachable-history representation; threshold , accuracy ; stopping-reward oracle , likelihood-ratio oracle M, and next-signal probability oracle
Output: Incentive-compatible contract within of , or a report that no finite budget exists
1: Subroutine VERIFY(B) 2: for all terminal histories 3: for do 4: for each history do 5: 6: 7: end for 8: end for 9: return 10: End subroutine 11: if CHECKFINITENESS() then 12: return “no finite budget” 13: end if 14: Using VERIFY(B) as a feasibility oracle, find by doubling and binary search 15: return
C.2 Proof of Theorem 2
Throughout, and the reachable signal tree through is finite. For and , . Hence, by the tower property, . Moreover, and , so all expected costs and payments below are finite.
The stopped change-of-measure identity gives , and analogously for the payment. Consequently,
We next show that returns the largest incentive violation. At time , stopping is mandatory, so . At a reachable history with , a rule either stops immediately or continues. For any rule continuing beyond , conditioning on the next signal gives
Equality is attained by following, after observing s, an optimal rule for the resulting history. Hence,
This is exactly the recursion in . Backward induction also shows that a maximizing rule stops at the first history where . Averaging over the first signal gives . Combining this with Eq. 10,
so implements exactly when .
Finally, implies
Since , the incentive violation for each fixed is affine in with nonpositive slope. Thus , as the maximum of finitely many such affine functions, is convex, piecewise linear, and nonincreasing.
Each backward pass visits every node and transition once, so requires arithmetic operations and oracle calls. Finiteness is handled below by one additional backward pass. Once finiteness is established, monotonicity justifies the doubling and binary search used in Algorithm 1.
C.3 Finiteness check
For , incentive compatibility is equivalent to
The coefficient of is nonnegative and vanishes exactly when . Hence a finite budget fails to exist precisely when there is a stopping rule with almost surely under while . Since the tree admits only finitely many stopping rules,
where the maximum of an empty set is .
The maximum in Eq. 12 is computed by the same backward recursion as VERIFY, with B = 0 and modified stopping reward
Thus stopping is permitted only below the likelihood-ratio threshold. The same backward-induction argument shows that the value at the empty history equals the maximum in Eq. 12. Accordingly, CHECKFINITENESS() returns true exactly when this value is nonpositive, requiring one additional backward pass.
At , the coefficient of is the total-variation distance between the stopped laws, so this reduces to the zero-total-variation obstruction in Theorem 1.
C.4 Numerically stable Bernoulli recursion
The subroutine VERIFY evaluates the stopping reward
at each state, where is a binary audit; for example, the minimum-budget likelihood-ratio audit uses . In the Bernoulli setting, a state is represented by , where is the number of failures among the first signals, and
Thus can be exponentially large or small in . Directly forming the likelihood ratio can therefore overflow or underflow in double precision well before the horizons of interest. Rescaling the final output does not resolve this, since the numerical error occurs inside the Bellman recursion.
We instead absorb the probability of reaching each state into the value function. Let
denote the probabilities of state under and , respectively, and define
The key identity is . Hence, with constant per-round serving costs and , the scaled stopping reward becomes
This expression involves only probabilities bounded by one and never requires forming itself. For the likelihood-ratio audit, even the test can be evaluated without forming the ratio: at cutoff one, .
The Bellman recursion can be written directly in these scaled variables. Since
we obtain
Because , multiplying both the stopping and continuation values by does not change which is larger. Thus the original Bellman recursion is equivalent to
with terminal condition . Finally,
The scaled recursion therefore produces exactly the same stopping decisions and root value as the original recursion, while avoiding the exponentially large likelihood ratios that cause numerical overflow.
D BETTING AUDITS
D.1 Service-level guarantee
Suppose , and is measurable with respect to the past. Then . If
then
Thus
so is a nonnegative supermartingale with .
Ville's inequality gives
Since for every stopping time ,
or equivalently
D.2 Likelihood-ratio interpretation
Assume now that
For any admissible predictable , define, at a reachable history ,
Nonnegativity follows from the restriction on , while
by the conditional-mean assumption. Hence is a probability kernel and
The chain rule for likelihood ratios therefore gives
Thus is exactly the likelihood-ratio process between the promised signal law and the alternative law induced by the chosen stakes.
For Bernoulli signals, let the promised and alternative laws be and , respectively, with . Taking and
yields
which are the one-step likelihood ratios for success and failure. Hence the corresponding betting process equals the Bernoulli likelihood-ratio process exactly.
D.3 Finding the minimal IC budget for a betting contract
Let denote the set of budgets for which is incentive compatible, assume , and let denote the backward pass of Section 4.1 with replaced by .
The reward identity Eq. (10) and the backward-induction argument in the proof of Theorem 2 use only that the payment is a function of the observed history, so they apply verbatim to . Hence , and if and only if . The audit is evaluated along the tree via , so each pass takes operations.
By the stopped change of measure, for each ,
(13)
which is affine in . Since is finite, is a maximum of finitely many affine functions of , hence convex and continuous. Thus is a closed interval, and, being nonempty and bounded below by 0, it has a least element .
Therefore, given any element of this interval, bisection finds the minimum one with precision in tries.
Suppose that deviating saves costs under every admissible stopping rule, that is, for all . By Eq. 13, if for some , then violates incentive compatibility at for every , while for every with a positive expectation the constraint at is a lower bound on . Consequently, under the assumption of , we have that if and only if
and in that case , so doubling from reaches a feasible budget after steps, after which the bisection above applies. Both checks take one backward pass each. The minimum above is computed by the recursion Eq. (11) with stopping reward . For the cost condition, the reward identity with zero payment gives , where is the stopping reward of Section 4.1 at , so its minimum over is computed by the same recursion with stopping reward .
We note that computing , as well as verifying the conditions above, requires the signal laws induced by both policies and their costs, through , and . Only the audit itself is distribution-free: is evaluated from the observed signals alone, and its level- guarantee relies only on the service-level condition.
E EMPIRICAL EVALUATION
All computations are run on a personal computer.
E.1 Qualitative Analysis
Reproducibility constants for min-budget and min-pay For Figure 2 (Left), we use , , , , and T = 3. The min-budget contract is computed using Theorem 1, while the min-pay contract is obtained from the linear program in Appendix B.1.
Reproducibility constants for the deterred set For Figure 2 (Center), the promised router is , the reference deviation is , and T = 3. The displayed region is obtained by evaluating the resulting contract against each candidate deviation .
Reproducibility constants for the worst-case stopping rule For Figure 2 (Right), we use p = 0.8, q = 0.2, , , and T = 10. The stopping rule shown is the maximizing rule returned by the dynamic program of Section 4.1.
E.2 Practical Considerations
We take accuracies and costs from the SWE-bench Verified Mini board of the Holistic Agent Leaderboard [HAL; 18, 14], read directly from its published table and retrieved on 4 October 2026. The benchmark is a 50-task subset of SWE-bench Verified [17], and we identify one task with one step of the subscription. We keep the SWE-Agent entries throughout, so that two routers differ only in the model they serve. An entry's reported accuracy is the fraction of the 50 tasks it resolves, which we read as the per-step probability of a passing evaluation; and are therefore the accuracies of the promised and the deviating router. Its reported cost is the total API cost of running the agent over all 50 tasks, so we set and to those totals divided by 50, an estimate of the expected cost of a single step.
Reproducibility constants for the role of For Figure 3 (Left), the promised model is Claude Opus 4.1 and the reference deviation is Claude 3.7 Sonnet, giving . We use horizons and vary over the range shown in the figure.
Reproducibility constants for partial information For Figure 3 (Center), we use the same model pair with and reference service level . We vary the betting stake ; the stake reproducing the likelihood-ratio audit is .
Reproducibility constants for deterring a family of models For Figure 3 (Right), the promised model is Claude Sonnet 4.5 High and the reference deviation is Claude Sonnet 3.7 High, with and . The resulting contract is evaluated against each of the remaining Claude routers in the leaderboard.