Manuscript Offprint
arXiv:2611.05835Pathwise-Budgeted LLM Routing: Online Allocation with K-Bit Tail-Cost Learning
Abstract
Firms using large language models under fixed budgets must decide which model to call and whether to retry a failed task. Because a call's charge is revealed only after completion, one long response can exhaust the remaining budget and leave later tasks unserved. Our objective is to maximize the number of tasks solved before service stops. We develop a contextual bandit policy, ADP-HT, which learns each model's task-specific success probability and constructs conservative cost estimates from coarsened response-length labels on a quantile grid with intervals. The policy weighs predicted success against these costs, adjusting the cost penalty to realized spending and the budget available per remaining task. Under calibration, local regularity, and grid-coverage conditions, we bound the excess allowance in the policy's conservative cost estimates. At a fixed sample size, increasing reduces the discretization term but increases the estimation allowance. At the tightest tested budgets, ADP-HT solves more than twice as many MATH500 and GPQA tasks as the best implemented baseline. It achieves the highest mean cumulative score at ten of fourteen RouterBench budgets. On LiveCodeBench, it outperforms a deployed commercial router in both default and cost-saving modes at the three lowest test budgets.
Keywords: Bandits with knapsacks; Pathwise budgets; Online resource allocation; Quantized feedback; LLM routing.
Contents
| 1 Introduction | 2 |
|---|---|
| 2 Literature Review | 4 |
| 2.1 Online Resource Allocation under Random Consumption | 4 |
| 2.2 Tail-Sensitive Learning with Coarsened Cost Feedback | 5 |
| 2.3 Cost-Aware and Sequential LLM Routing | 5 |
| 3 Problem Statement | 6 |
| 3.1 Tasks, Models, and Information | 6 |
| 3.2 Decision Process | 7 |
| 3.3 Pathwise Budget and Stopping Rule | 7 |
| 3.4 Objective | 8 |
*Authors are listed in alphabetical order.
H. Qin is with the Department of Industrial Systems Engineering and Management, National University of Singapore, hzqin@nus.edu.sg. S. H. Yu is with The Wharton School of Business, University of Pennsylvania, Philadelphia PA, USA, hyophie@wharton.upenn.edu. Y. Zhang is with the Department of Industrial Engineering, Tsinghua University, Beijing, China, zyw23@mails.tsinghua.edu.cn. Z.H Zhang is with the Department of Industrial Engineering, Tsinghua University, Beijing, China, zhzhang@tsinghua.edu.cn.
Y. Zhang is the corresponding author.
4 Methodology 8 4.1 Reward Learner ..... 9 4.2 Cost Learner ..... 10 4.3 Dual-Pace Controller ..... 12 4.4 Model Selection and Retry Gate ..... 13 5 Numerical Experiments 15 5.1 Experiment 1: Routing and Retries Under a Binding Budget ..... 15 5.2 Experiment 2: Comparison on a Public Benchmark ..... 17 5.3 Experiment 3: Comparison with a Deployed Commercial Router ..... 19 6 Conclusion 19 EC.1 Proof and Calibration Details 25 EC.2 Implementation and Evaluation Details 30 EC.3 Cost-Head Ablation on RouterBench 35 EC.4 Validation and Analysis in a Numerical Example 36 EC.5 Tail Costs and the Value of Future Service 40
Much of the literature on LLM routing treats model choice as a quality-cost trade-off for the current request. Cascades decide whether to escalate an inexpensive response, while supervised routers learn which model is likely to deliver sufficient quality at an acceptable expected cost [CZZ24, AMA+24, DMW+24, OAW+25, SPdO+26]. This expected-value perspective is natural when requests can be considered independently or spending is controlled on average. However, a finite pathwise budget in most LLM services is enforced based on cumulative realized spending along the actual sequence of calls, rather than on expected spending. This stopping rule changes the consequences of call-cost uncertainty. A call's realized charge becomes known only after completion, and unusually long responses are difficult to anticipate. One call can therefore exhaust the remaining budget and end service for every later task. Its consequence includes both the current charge and the loss of future service. Optimizing expected quality against expected cost request by request does not control this stopping risk.
Consider a developer with a $100 monthly budget for model calls on OpenRouter. Coding tasks arrive one at a time, from a short unit-test fix to a difficult multi-file change. For each task, the developer chooses among models including GPT-5.6 Sol, Claude Opus 5, Kimi K3, GLM 5.2, and others. The models differ in price and in the kinds of tasks they solve well [Ope26c, Ope26d]. Only after a call finishes does the developer observe its total token count and exact provider charge. If the response fails, the developer must decide whether another call, now carrying the failed exchange in a longer prompt, is worth its cost or whether to abandon the task and preserve budget for later work. Each selected call reveals its model's outcome and response length, whereas the outcomes of unselected models remain unknown. The challenge is to learn which model fits each task while preserving enough budget to complete as many later tasks as possible.
The same operating structure arises when firms assign API budgets to employees, when an LLM customer-service system handles cases of different difficulty, and when a metered AI service allocates model access across client requests. We focus on settings with three features. Tasks are processed online under a pathwise budget. Call cost is unknown at admission and can vary substantially in its upper tail. Success and cost profiles must be learned from selected calls. These features lead to our central operations question: how should an operator route and retry a sequential task stream to maximize the number of tasks completed before a finite LLM budget stops service?
To answer this question, we formulate LLM routing as a K-bit Pathwise Contextual Bandits with Knapsacks problem and develop ADP-HT (Adaptive Dual-Pace Hybrid-Threshold), an online policy that weighs each call's chance of solving the current task against the future service its uncertain cost puts at risk. Our contributions are fourfold.
First, we formalize LLM routing under a budget with a halt-after-crossing rule, treating each model as an arm. A successful response removes a task from the stream, a failed task may be retried or abandoned, and the first call whose charge crosses the budget ends service. The objective is to maximize the number of tasks solved before this stopping time. LLM's response lengths are heavy-tailed and difficult to predict [WQX ], and a single long response may exhaust the remaining budget and terminate service for all future tasks. For such a halt-after-crossing budget, the cost needs to be forecast in a risk-aware manner rather than an expected point estimate sense. We therefore introduce a K-bit cost-shape channel, which discretizes response length into intervals and estimates the exceedance probability at each interval boundary. This changes the cost prediction problem from estimating the exact response length to estimating whether the response length would be longer or shorter, which is more robust and reliable. A larger K improves the resolution of prediction but may increase the estimation difficulty, which introduces a trade-off between resolution and precision. This structure extends the random-cost, halt-after-crossing formulation of [CES20] from repeated arm pulls to an online task stream with per-task value, router-controlled retries, and K-bit cost prediction.
Second, we give an implementable online policy for choosing models and retries. A hybrid reward learner combines a shared low-dimensional component with model-specific adjustments to form an optimistic solve probability. Threshold-survival heads use the quantized targets to estimate a pre-call cost bound at a chosen tail tolerance. The selector subtracts that shadow-priced cost bound from the optimistic solve probability, so an expensive model remains eligible when its chance of solving the task compensates for the budget it would consume. A dual-pace controller adjusts the shadow price from realized spending and smooths the pacing response through recent average costs. After a failure, the retry gate raises its margin with the attempt index and spending beyond the revised task allowance.
Third, we characterize the K-bit trade-off between resolution and precision and show that its discretization and estimation terms are jointly order-tight under the stated confidence calibration. The implemented grid divides a core range containing the more common response lengths into quantile-based intervals and reserves one tail interval for the remaining long responses. Our main theorem separates the excess cost allowance arising from grid coarseness, warm-data placement of the grid edges, and simultaneous estimation of the threshold-crossing probabilities. More bits reduce the discretization term but increase the estimation allowance at a fixed sample size. The result applies when the target response-length threshold, including its estimation allowance, remains in the core. The same argument extends to other fixed grids through their local edge spacing. We also ask how the value of tail protection changes with the remaining workload even when cost distributions are known, by solving a two-model specialization with one call per task. At a fixed budget, the optimal first choice can move from the risky model to the predictable model and then back as the number of remaining tasks increases. Predictable calls protect future service, but their higher ordinary cost can displace useful calls when many tasks remain.
Fourth, three numerical experiments evaluate the policy, from benchmark task streams to a deployed commercial router. At the tightest tested budgets, ADP-HT solves an average of 216.2 MATH500 problems and 85.0 GPQA questions, more than twice the best implemented online comparator in each dataset. On ROUTERBENCH, the implemented ADP-HT policy leads in the descriptive ranking at all eight tight budgets and ranks first in ten of fourteen budgets overall. In the commercial experiment, ADP-HT's test phase solves 682 problems while incurring 22.86.
The rest of the paper is organized as follows. Section 2 reviews the related literature to situate our formulation among bandits with resource constraints, tail-aware learning, and cost-aware LLM routing. Section 3 defines the formal model including the task stream, exact budget ledger, and stopping rule. Section 4 develops ADP-HT, which prices every call and retry against the budget it puts at risk and characterizes the K-bit trade-off in pre-call cost precision. Section 5 evaluates the policy in three experiments, from live routing with retries to cross-task allocation on a public benchmark and a comparison with a deployed commercial router. Section 6 concludes.
Notation. Throughout the paper, we write and for the indicator of an event. For , truncates to . A tilde marks a random potential outcome and the same symbol without a tilde its realized value, while a hat marks a quantity estimated from data. Finally, hides polylogarithmic factors.
2 Literature Review
Our work draws from and contributes to three streams of literature, which we connect by examining how a depleting pathwise budget and coarsened tail-cost information jointly shape model-choice and retry decisions.
2.1 Online Resource Allocation under Random Consumption
Online resource allocation provides the primary operations perspective for our problem. In revenue management, bid prices express the opportunity cost of consuming capacity now rather than reserving it for later demand [TvR98, Top09], and online-allocation policies extend this logic by updating resource prices as demand and consumption unfold [BLM23]. The same logic applies to an LLM budget. Every admitted call spends capacity that could otherwise serve a later task, and our policy prices each call against that displaced service.
Bandits with knapsacks bring learning into this opportunity-cost framework. Canonical models combine selected-arm feedback with a finite resource [TTCRJ12, BKS18]. Contextual and regression-oracle variants allow reward and consumption to depend on observed covariates [AD16, SZSF24, ZKSV22]. Related learning problems arise in inventory control and reusable-resource pricing [TDSY26, JSS22]. Random-cost formulations allow jointly distributed costs and rewards that are observed after selection [CES20]. Our formulation retains the finite budget, random consumption, and stopping upon depletion, and applies them to an online stream of tasks.
Within this stream, [CES20] provides a close starting point. Each pull generates a random cost-reward pair, play ends when cumulative cost first exceeds the budget, and the last pull's reward is retained. Their model allows signed and potentially unbounded costs and rewards. We focus on nonnegative token charges, stop when spending reaches or exceeds the budget, and retain the final response's reward. We add three operational features to this post-call accounting. First, the allocation unit is an online stream of distinct tasks rather than repeated arm pulls, so value is earned only when a task is completed and a verified task leaves the stream. Second, continuation is itself a decision. After a failed call, the policy chooses whether another call should compete with unserved tasks for the shared budget. Third, the cost predictor uses quantized response-length targets to estimate the upper tail of the next call's cost. This tail matters for both model choice and continuation because a large realized charge can end service for later tasks.
2.2 Tail-Sensitive Learning with Coarsened Cost Feedback
Risk-sensitive and safety-constrained bandits protect different aspects of sequential performance. Conservative policies require cumulative performance to remain above a prescribed fraction of a baseline, with guarantees in expectation or with high probability [WSLS16]. Related formulations address anytime cumulative constraints [LLSY21] and chance constraints on resource use [CKMZ19, LNSZ21]. Gambler and survival bandits model termination at a ruin threshold for accumulated reward or wealth [PVG+21, RHS24b]. Quantile forecasts describe uncertainty in service outcomes [ATM23], while quantile-bandit and sequential-estimation methods estimate reward quantiles and identify arms by their quantile performance [ZO21, HR22]. Our focus is the conditional upper tail of the next call's cost.
A second stream shows that aggressively coarsened feedback can support effective shape learning, which is operationally relevant when the exact cost is unknown at admission and hard to predict. Communication-constrained bandits quantize rewards into a few bits while preserving learning performance [HYF22], and one-bit quantile bandits use adaptive threshold queries to identify the arm with the highest reward quantile [LS25]. We bring this coarsened-feedback idea to cost-tail estimation. The exact provider charge updates the pathwise ledger, while the cost learner receives only which of fixed response-length intervals contains the call. The resolution parameter thereby becomes an information-design parameter, since a finer mesh localizes the conditional tail more closely but enlarges the set of thresholds estimated simultaneously, and our analysis characterizes this finite-sample trade-off for the algorithm we propose.
2.3 Cost-Aware and Sequential LLM Routing
LLM routing methods differ in whether they enforce a budget through realized cumulative spending across tasks and whether they jointly model uncertain call costs and retries. Cascades such as FrugalGPT and AutoMix escalate from an inexpensive model when its response is judged insufficient [CZZ24, AMA+24]. HybridLLM, RouteLLM, and CARROT instead learn a request-level choice along a quality-cost frontier [DMW+24, OAW+25, SPdO+26], and RouterBench supplies an offline environment for comparing such routers [HBL+24]. Adaptive methods reach further. PILOT allocates estimated costs over a known query set [PMD+25], [PDL+26] control up to calls within a query and screen models by confidence bounds on mean cost, Pareto-Bandit paces an average per-request cost ceiling over an open-ended stream [TM26], ACQB uses user retrials as implicit feedback for joint routing and scheduling [BSL26], and SeqRoute and MTRouter learn offline from logged trajectories how a model choice bears on the terminal outcome of a session [XZW26, ZLW+26]. [BTZ26] develop OSCAR and analyze which LLM configurations to call and when to stop while searching for the next simulator-certified improvement. Related stopping decisions arise in contextual search [BCW26] and LLM-based sequential testing [LLL+26]. Our decision unit is instead a shared task-stream budget that binds pathwise by halting, so a call's consequence includes the future service its realized cost displaces, and the exact cross-task ledger, the tail-cost bound for the next call, and router-controlled retries must be modeled jointly. The router also learns online from chosen-arm feedback on verifier-checked tasks rather than offline from logs.
3 Problem Statement
We consider a budget holder who calls LLMs directly under a single monetary or token amount fixed for the period, such as the developer of Section 1. Tasks arrive online, one at a time, and each is served with one of the available models. After a failed response, the decision maker may retry with the failed exchange added to the prompt or leave the task for manual work. The objective is to maximize the number of tasks completed before the budget is exhausted. Each call both draws down the budget and generates data about the model that was called, so the exploration-exploitation trade-off is central to the problem. A model's output is observed only after the call returns, and its length, the part of the charge that is unknown at admission, is difficult to predict accurately in advance, even for a fixed prompt on a fixed model [WQX ]. The remainder of this section fixes the primitives of the problem, namely the task stream, the information available before a call, the pathwise ledger, and the rule that stops service when spending reaches or crosses the budget.
3.1 Tasks, Models, and Information
We model this problem in a bandit framework. Let be the finite set of available LLMs and regard each one as an arm, so that is the number of arms. The total number of tasks and the total budget are known in advance, but the contents and difficulty of future tasks are unknown until they arrive. The tasks arrive online, one at a time, and are served under this budget. For each task, the decision maker selects and calls an LLM in an attempt to solve it. We call the policy that makes these model and retry choices the router. A task can receive at most calls and leaves the stream after its first successful response, after the router abandons it, or after all attempts have been used. For bookkeeping, we order the potential task-attempt steps lexicographically and index them by , where is a task and an attempt. Conversely, denotes the task and attempt associated with step , with and . Let indicate whether step executes a call. For a first attempt when there is still remaining budget, we always have . While for a retry, only if the router chooses to call rather than abandon and move to next task. For an abandoned or solved task, for every later step with . And we write for the arm called when . When , the problem contains one model choice per task and no retry decision.
State and information. Before step , the router observes a state in a state space , a context summary constructed from known information, including the current prompt, the failed responses already obtained for task , the attempt index , and the budget ledger. Let be the -field generated by all states, decisions, outcomes, and ledger values realized through step together with the current state , so that is the information available before the response, and the sequence is the pre-outcome filtration. Every pre-call quantity, including the state, the budget, the decision to call, and each selection score, is -measurable, whereas the response and its cost are not. We take to be sufficient for the response, in the sense that the solve probability and the response-length distribution of a called arm depend on the past only through , so the conditional means and survival probabilities used in Section 4 are functions of . The router's estimators, shadow price, and pacing multiplier, by contrast, depend on the whole realized path, so decisions are required to be -measurable rather than functions of alone. The policy later uses two deterministic views of the observed state, a reward feature and, for each candidate arm, a cost feature where we use and as upper or lower indices to denote features for reward and cost, respectively.
Outcomes and feedback. If a candidate arm is called in state , it produces a solve indicator and an output length , where is a known upper bound on response length (GPT-5.6 Sol, for instance, caps completions at 128,000 tokens [Ope26a]). We assume the verifiable binary success feedback becomes available after the call. For example, an execution grader can run code tests for a coding task, or a verifier can compare a mathematical answer with its reference answer. Providers charge by the token, so the call costs
where is the prompt length in tokens under arm 's own tokenizer, known before the call, and are the known input and output prices per token. Only the selected arm reveals outcomes. Its realized values are , and . The input side of the charge is therefore known at admission, whereas the output side is not.
3.2 Decision Process
Let be the exact spend before step and the remaining budget. Each step proceeds in four stages.
(i) Observe. The router reads the state , including the prompt, retry history, and current ledger.
(ii) Decide. The step is live if task is unsolved and not abandoned and . At a live first attempt the router selects an arm and calls it. At a live retry it either calls an arm or abandons the task. Set for a call and otherwise. A task that has been solved or abandoned is no longer live, so at every later step with .
(iii) Realize. If , the selected arm returns and the ledger becomes . If , no call is made, , and .
(iv) Transition. If and , task is solved and the stream advances. If , , and , the failed response is appended to the state used for the next attempt. A failure at leaves the task unsolved and advances the stream, as does an abandonment decision taken at stage (ii).
Thus every executed step includes model selection, while admission control begins with the first retry. Figure 1 draws the resulting process at the task-attempt level, with step subscripts suppressed. The router decides from pre-call information, observes the selected model only after execution, and then updates both the state and the budget, so that one realized charge tightens every later admission.
3.3 Pathwise Budget and Stopping Rule
Executed charges accumulate in the ledger . A call can be admitted whenever , but its realized charge may exceed the remainder. Service stops after the first call that reaches or crosses the budget, at

Figure 1: Decision flow of the task stream under the budget .
with when no crossing occurs. The crossing response is observed and receives credit if it solves the current task, but for every later step . This halt-after-crossing rule therefore limits future admissions rather than truncating a response already in service.
This pathwise rule makes the consequence of an expensive call depend on its position in the task stream. Beyond the current charge, its loss includes the later tasks the charge removes from service, so the budget is a one-dimensional, absorbing capacity constraint rather than an average-cost penalty applied independently to each request.
3.4 Objective
Let be the class of nonanticipating policies, those whose step- decisions are -measurable. The router maximizes the expected number of distinct tasks solved before service stops, with denoting expectation under the policy :
This objective values each unit of budget through the tasks it keeps serviceable, rather than through a per-call quality-cost ratio.
4 Methodology
We develop ADP-HT, an online policy for LLM routing, which is motivated by the bid-price principle of online resource allocation. Consider a budgeted bandit problem. In each round, the decision maker selects an arm, receives a reward , and consumes units of a limited resource. Resource spent on the current pull is no longer available in later rounds. Then each arm's value can be measured by the reward it produces minus the opportunity cost of the resource it consumes, which can be expressed as
(4) where is the shadow price, the opportunity cost of consuming one unit of budget. And can be viewed as the net value of the action, so the decision maker should select the arm with the highest .
However, this score is not directly available in LLM routing. In this setting, each arm corresponds to a candidate LLM. The reward records whether its call solves the current task, with for success and otherwise, and is the budget charged for the call, but the router does not know either exactly before a call is made. For example, even when the prompt length and token prices are known, the number of output tokens is unknown until the response is generated, and the exact charge cannot be determined in advance. So it has to learn the solve probability from selected calls and estimate the cost before the response returns. Because one long response can exhaust the remaining budget, the cost term should take this risk into account. The shadow price should also track realized spending adaptively to better utilize the remaining budget. And for tasks that fail on the first attempt, the router needs to decide whether to retry the same task or preserve the budget for later tasks. The rest of this section builds ADP-HT based on the score (4) with modifications for these challenges.
ADP-HT supplies these quantities in four modules designed for LLM routing. For the reward (see Section 4.1), a hybrid learner combines a shared task-difficulty component with a model-specific adjustment and reports an upper confidence bound (UCB) on the solve probability. For the cost (see Section 4.2), we utilize a -bit prediction of the response length to construct a one-sided pre-call cost bound that covers the tail of the response-length distribution. It is difficult to predict the exact output tokens for a LLM, but it is much easier to predict whether the response will be short, medium, or long. This motivates the -bit threshold-survival heads, which can help the router predict more reliably with a loss of resolution, introducing a trade-off between resolution and precision. The shadow price is controlled by a dual-pace mechanism (see Section 4.3). Its fast component updates the price directly from the latest call's charge, while its slow component updates a pacing multiplier from an exponential moving average of recent charges. These components adjust the cost penalty and the current task's spending reference in response to realized spending and remaining capacity. Finally, the retry gate (see Section 4.4) decides whether a failed task should continue competing for capacity, using the current pre-call score of the selected candidate and a margin computed after the previous failure. The margin rises with retry depth and with spend beyond the revised task allowance. The following subsections describe these modules, and Algorithm 1 gives the full policy.
4.1 Reward Learner
The first term of the score (4), the reward that a model solves the current task, is provided by the reward learner. Estimating it separately for every model wastes information because a difficult prompt tends to be difficult for several models, and a call to any model reveals something about that common difficulty. Pooling all calls into one predictor creates the opposite problem, because models have different strengths. The hybrid reward learner therefore combines a shared task component with a model-specific adjustment.
The reward feature of step is a high-dimensional prompt embedding, and the calls available to each model are limited in online routing. The shared component therefore works on the projected feature , where is a fixed projection matrix with orthonormal rows and , so the pooled block is estimated in a much smaller space. An unregularized fit would still be sensitive to directions that the executed calls sample poorly, so we estimate both components jointly under a ridge penalty, which limits the influence of those directions [Has20].
Every executed call updates the shared sufficient statistics and the local sufficient statistics of the selected model. The fit returns a shared coefficient and a coefficient for each model .
The first term reads how difficult the task is for all models, and the second characterizes each model's specific performance on that task. This additive structure follows the hybrid linear upper-confidence-bound (LinUCB) algorithm [LCLS10]. The fixed projection reduces the shared block's dimension, motivated by random-projection methods for dimension reduction [Ach03]. The detailed implementation is provided in EC.2.
A point estimate alone would favor models already sampled often and could prematurely discard a capable but less-tested model. The learner therefore adds the uncertainty of the same ridge fit, which is large when the current model-task pair is poorly covered by past calls:
where is the reward-exploration scale, clipping keeps the score in , and the inner guards against a negative variance proxy produced by rounding. The selector uses rather than the point prediction, so fresh evidence can overturn an estimate built from few calls, leading to a balanced exploration-exploitation trade-off.
4.2 Cost Learner
The term of (4) is supplied by the cost learner. For a call to LLM , the cost consists of two parts, an input charge and an output charge, with known per-token prices and . The input side of the charge is already known at admission (the prompt), so the quantity to forecast is the response length, for which the natural device is a point estimate. Such an estimate is unreliable, because a prompt does not determine a length. Even holding the model and the decoding configuration fixed, repeated calls on the same prompt trace out a heavy-tailed distribution of output lengths rather than one deterministic value [WQX+26], so the estimate reports the center of a distribution whose spread is precisely what matters. The consequences of prediction error are asymmetric. Overprediction lowers a model's selection score and can discourage a retry that the budget could have afforded. Underprediction can instead favor a response whose realized charge crosses the budget and ends service for every later task. The selection score therefore needs a statement about the tail of the length distribution rather than only its center.
The -bit mechanism takes the place of that point estimate. The resolution parameter determines the number of response-length intervals, . Rather than predict precisely how many tokens a response will contain, the router first discretizes the range of possible lengths into intervals, then asks at each interval boundary whether the response will run past it, and reports the upper edge of an interval as its final prediction. This can lower the difficulty of the prediction, and the reason is easy to see intuitively. At , for instance, the router predicts only whether a response will be short or long. That single bit can be easier to get right than an exact point estimate, and it also helps control the risk that a misprediction lets an overlong response exhaust the remaining budget. The price of the lost resolution is just as visible. A coarse grid limits how precisely the learner can locate the target response-length threshold. A larger supplies more thresholds, and every call updates all heads of its selected model. The trade-off comes from requiring confidence across more estimates, which increases the estimation allowance at a fixed sample size under the stated confidence calibration. The analysis following Algorithm 1 quantifies this trade-off between resolution and precision.
We call this coarsened signal the -bit cost-shape channel, and construct it as follows. In the formal model, the intervals are delimited by edges , where is the known maximum output length. These edges are chosen before the run and fixed during online decision processes. The edges can be constructed from the warm-start samples. For example, for and an equal-probability grid, the three interior edges are chosen to be the 25%, 50%, and 75% quantiles of the historical response length distribution of warm-up calls or stored user datasets. In our implementation, we instead use warm-start quantiles to place
intervals within a core range and reserve one interval for the modeled tail, where can be chosen and updated by the maximum observed length. This prevents the longest possible response length from influencing the core resolution. Thus gives three core intervals and one tail interval. The empirical top edge and the construction details are given in EC.2.1. At each threshold, we observe whether the response ran past the edge, an indicator we write . It then updates every threshold head of the selected model The formal analysis also allows other fixed, strictly increasing construction methods, such as equal-width partitions. For other grids, the extension in EC.1.5 uses the distance to the next available edge. This term is no larger than the widest interval, . Thus, the edge choice affects the size of the bound, but not its structure.
For candidate model and edge , the learner estimates the exceedance probability
Here is the length model would return in state , and the conditioning is on everything the router knows before the call. Note that since is an empirical upper bound in the implementation, actual response lengths may exceed it, so the probability in (7) can be positive even for .
For each model-edge pair , a threshold head uses ridge regression fitted on past calls to model to predict the exceedance label from the cost feature , where combines the projected prompt feature with pre-call information such as retry depth, input length, and the previous call's outcome and cost. With cost-exploration scale , the head reports the raw upper confidence bound
Here is the fitted exceedance probability, and measures estimation uncertainty at the current cost feature. The uncertainty measure is common to all heads of model , because they use the same past calls, cost features, and ridge regularization and differ only in their exceedance labels. EC.2 gives the regression statistics and the expression for in detail.
True exceedance probabilities are nonincreasing in the threshold index , since a response that exceeds also exceeds every shorter edge. But heads fitted separately need not respect that ordering in finite samples. The router restores it with a single sweep from short to long, replacing each bound by the smallest one seen so far as follows.
The reported bound is therefore nonincreasing in the edge. We call this correction the monotone projection, which restores coherence without adding information.
To obtain a response-length bound, fix a tail tolerance specifying the maximum acceptable exceedance probability. The first-safe-edge rule selects the smallest edge whose reported bound is at most . If none qualifies, it falls back to the top edge . The resulting edge length is
Known token prices convert this length into the cost bound used in the selection score and retry rule,
The tolerance can be tuned on validation data or chosen according to the user's risk preference. Holding the reported bounds fixed, decreasing will increase the selected edge and the resulting pre-call cost bound.
where is the prompt length under model 's own tokenizer, a function of a because tokenizers differ enough across model families that one prompt yields a different token count, and hence a different input charge, on each candidate [PLMTB23].
4.3 Dual-Pace Controller
The dual-pace controller sets the shadow price in (4) and the budget references used to evaluate each call. At decision step s, the remaining budget needs to support the tasks remaining in the stream, including the current task. Since the difficulty of future tasks is unknown, we use the equal share as an initial spending reference. A strict per-task cap at this share can be too restrictive. If inexpensive tasks repeatedly leave part of their share unused, the share available to later tasks increases. A strict cap can therefore limit spending on earlier tasks even when budget is left unused at the end. Allowing unrestricted spending creates the opposite risk, because early tasks may exhaust the budget before later tasks are served.
ADP-HT uses the dual-pace controller to manage this tradeoff. A pacing multiplier adjusts the spending reference for the current task based on recent average call costs. A shadow price adjusts the cost penalty in model selection based on the cost of the latest call. The former responds to the recent spending pattern, while the latter responds directly to the latest call.
We define the task budget reference and step budget reference as
where is the number of attempts remaining for the current task, including the current attempt. The task budget reference provides a scale for the cost normalization, while the step budget reference provides the spending reference for updating . The small constant keeps denominators positive.
After a call returns, the router observes its exact cost and updates an exponential moving average (EMA) of call costs,
where is the weight on the latest charge. The initial average is obtained from the historical data.
The shadow price compares the latest charge with the step allowance, whereas the pacing multiplier compares the equal-share reference with the updated average cost. With learning rates , the two multiplicative updates are
where the clipping bounds , , , prevent extreme updates, and the outer clips and keep the shadow price and pacing multiplier within reasonable ranges.
For each LLM call, if the realized cost exceeds the step allowance , the shadow price rises, lowering the score of expensive models in the next step. If the realized cost is below the allowance, the shadow price falls, leading to more aggressive spending. The pacing multiplier compares the equal-share reference with the moving average of recent costs. If the average cost is below the equal share, rises, allowing more budget for the current task. If the average cost exceeds the equal share, falls and thus tighten the budget. The use of a moving average makes pacing less sensitive to a single charge, while the shadow price responds to that charge directly. The dual-pace controller therefore adapts to both the realized spending path and the recent cost pattern, which helps avoid overspending and underspending adaptively.
4.4 Model Selection and Retry Gate
With all modules above, the router computes the score for each model arm and selects the one with the highest score as follows:
The score (15a) aligns with the core design of score (4). The cost is normalized by the task budget reference , which is dynamically adjusted by the remaining budget and the recent spending pattern. The shadow price changes with the realized cost of the latest call, reflecting the current scarcity and value of the remaining budget. By multiplying the normalized cost by the shadow price, the cost can be translated into the same scale as the reward , allowing a direct comparison. A model with higher possible reward and lower cost will have a higher score, and the models with higher rewards but higher costs may also be preferred. The score therefore balances the reward of solving the task with the cost of the call, and the model with the highest score is selected for step . Ties are broken first by the optimistic solve probability and then by a mean-cost proxy, both recorded in EC.2.
Equation (15) determines which model to call. After a failed attempt, the router must decide whether to make another call or move to the next task. A further attempt can exploit the failed exchange, but it starts from a longer prompt and may also fail with higher cost. The retry gate therefore evaluates this choice before the next call using accumulated cost and remaining budget.
Suppose attempt fails and leaves . The router records the exact charge, updates the dual-pace controller, and recomputes the task budget reference from the smaller post-call budget as with , where is unchanged because the failed task is still unsolved. The exact spend on the current task through step is , where indicates whether step executes a call. Using this sum, the router computes a retry margin that rises with retry depth and spending beyond the revised task budget reference as follows.
where . The base term is the required retry margin, penalizes deeper retries, and penalizes overspending. This retry gate aligns with the LLM's practical behavior, because a retry after multiple failures is less likely to succeed, and the cost will be higher because the prompt is longer with the failed response appended [LHZN26]. After computing and rebuilding the next state , the router reevaluates all candidates using the updated learners and controller. The task continues if and only if . Algorithm 1 summarizes the overall execution of ADP-HT.
Algorithm 1 ADP-HT policy.
Require: Tasks , arms , budget , retry limit , resolution parameter , tail tolerance , and warm of calls executed before the stream.
Ensure: Solved-task count SOLVED and realized cost .
- Replay to fix the edges and initialize both learners, , , and and set . initialization
- for to do
- Set and .
- Observe and build its first-attempt state .
- for to do
- if then halt.
- Compute and using (12).
- for do
- Compute using (6) and using (11).
- as in (15a).
- end for
- Select .
- if and then break; otherwise execute the call.
- Observe and update both learners.
- Set and .
- Update , and in that order using (13)–(14b).
- if then mark task solved and break.
- if or then break.
- Recompute and using (16), and append the failure and rebuild the next state.
- end for
- end for
For Algorithm 1, we capture the -bit trade-off in the pre-call cost bound. A larger creates a finer grid and produces a cost bound with higher resolution, while requires more data and effort to update all threshold heads. We quantify this in the following theorem.
Theorem (Informal). Given , the gap between the true conditional cost quantile and the pre-call cost bound in (11) satisfies the following order bound under the calibration, local tail-margin, core-coverage, and grid-spacing conditions in EC.1, with the remaining parameters fixed:
where is the number of all calls used to fit model 's cost heads.
A formal theorem statement and its proof are provided in EC.1. The resolution term comes from grid rounding and decreases as the grid becomes finer. The precision term is the allowance for simultaneous estimation across all threshold heads and increases with at a fixed sample size under the stated calibration. EC.1.4 gives a matching construction establishing joint order tightness under the stated calibration w.r.t. (17).
Holding reward estimates and controller values fixed, a larger estimated cost bound can lower a model's score in (15a). The -bit trade-off can therefore affect model selection and retry decisions. EC.1.2 bounds the one-step quantile-score loss, while Section 5.1.2 evaluates tasks solved and EC.2.7 checks empirical coverage, providing practical guidance on choosing .
We next examine how the value of tail protection varies with the number of remaining tasks. Suppose we route identical tasks, with one call per task and total budget , using two models with known distributions. The predictable model has deterministic cost and success probability . The risky model has success probability . It costs with probability and with probability , where . A response that reaches or crosses the budget is still completed and, if successful, counted before service stops.
It is easy to construct an instance in which every fixed mean-cost score prefers . For example, take . Then has both a higher success probability and a lower mean cost. Thus, for every , the score (4) prefers .
However, the budget stopping rule changes this conclusion because a high-cost call to may end future service. With few tasks remaining, there is little future service to lose, so is better. As more tasks remain, avoiding termination protects enough future service to justify choosing . With many tasks remaining, however, the extra cost of uses budget that could pay for several cheap calls to , so becomes better again.
This example shows how the number of remaining tasks changes the optimal first choice. Even when has both a higher success probability and a lower mean cost, the optimal first choice moves from to and then back to as the number of remaining tasks increases. A fixed score whose predictions do not change with the number of remaining tasks cannot reproduce these changes. ADP-HT uses a state-dependent cost penalty: the effective price on the cost bound in (15a) responds to realized spending and the remaining budget per unfinished task. The example yields the following structural insight.
Remark 1. For a given budget, the value of tail protection can rise and fall as the number of remaining tasks increases. With few remaining tasks, there is little future service to protect. With many remaining tasks, the extra cost of tail protection displaces cheap risky calls. The optimal first choice can therefore be risky, then predictable, then risky again, which should be adaptively reflected in the model score.
This analysis motivates a state-dependent cost penalty. EC.5 gives the formal results and distinguishes the optimal price in the two-model setting from ADP-HT's adaptive rule; in particular, fixed initialization cannot reproduce both backlog reversals.
5 Numerical Experiments
We conduct three experiments under the operating rules of Section 3. Experiment 1 (Section 5.1) compares the implemented policies on live MATH500 [HBK⁺21] and GPQA [RHS⁺24a] streams, with retries. It examines performance across budgets and sensitivity to the resolution parameter , the retry gate, and pacing. Experiment 2 evaluates adapted configurations on a public benchmark (Section 5.2), and Experiment 3 compares test-time allocation with a commercial router provided by OpenRouter (Section 5.3). We also conduct experiments in EC.3 and EC.4 to examine the -bit mechanism through cost predictor ablations and assess how closely ADP-HT approaches the dynamic programming optimum. All experiments run on a MacBook Air with an Apple M4 chip and 16GB of RAM.
We compare ADP-HT against four implemented policies from the multi-LLM routing literature and a deployed commercial router. Budget-aware (BA) and Position-aware (PA) LinUCB [PDL⁺26] are budget-aware contextual bandit routers. ParetoBandit [TM26] is ported to the finite stream with its primal-dual reward-cost rule intact, and Greedy LinUCB always calls the arm with the highest UCB, standing in for a budget-unaware online router.
5.1 Experiment 1: Routing and Retries Under a Binding Budget
We use a 20%/80% stratified split of each dataset into warm and test streams, with five shared-warm-start replicates per dataset. The warm stream is used to construct the warm-up data to initialize the predictors, which is excluded from budget accounting. And the budget is for the test stream only. A task may receive at most calls and leaves the stream after its first verifier-confirmed success, and the outcome is the number of distinct test tasks solved before service ends. The MATH500 budget grid is USD, to which GPQA adds 0.80 and 1.00. The tightest budgets cover only a small fraction of the stream, so the grid spans the scarcity regimes the model targets. Every policy faces the same five-model menu, task order, prompt constructors, verifier, local representation, seed-specific warm log, and cost accounting; the warm log is generated once by unconstrained Greedy LinUCB and replayed before each finite-budget run. EC.2.2 reports the details.
5.1.1 Results
Figure 2 reports the operating frontiers. ADP-HT's mean solved-count advantage over the budget-aware comparators is largest at tight budgets and narrows as the budget increases. At it solves 216.2 MATH500 problems and 85.0 GPQA questions against 100.8 and 29.8 for Position-aware LinUCB, the strongest implemented comparator in both datasets, or more than twice as many in each. At the largest budget of each dataset, the advantage over the best of BA, PA, and ParetoBandit is 2.6 and 4.6 tasks. Budget-unaware Greedy, far behind at tight budgets, closes to within twelve tasks on MATH500 and has a similar mean solved count on GPQA.

Figure 2: Performance on MATH500 and GPQA streams.
Converting the budget into completions is not the same objective as spending little. At on GPQA, ParetoBandit solves 235.2 questions for about 0.30. ADP-HT nevertheless has the higher solved-count mean at every tested budget, with grid-averaged advantages of 44.8 tasks on MATH500 and 27.9 on GPQA. Because the same warm replay re-enters the analysis at every budget of its seed, budget cells are not independent replicates. A two-level paired bootstrap of that difference yields 95% percentile intervals entirely above zero in all six dataset-baseline comparisons. EC.2.5 reports its construction and the cell-level means behind Figure 2.
The realized paths help describe how ADP-HT uses the budget. It uses 93.4% of the nominal budget on average across the MATH500 grid, against 75.7–81.5% for BA, PA, and ParetoBandit. This greater utilization is consistent with pacing releasing unused budget, although the comparison does not isolate its contribution. As the budget expands, the policy shifts calls from inexpensive models toward more capable ones. Calls per task on MATH500 first rise as second attempts become affordable and then fall when stronger first calls enter, whereas on GPQA retries remain common because first attempts fail more often. The remaining unsolved tasks account for a disproportionate share of spending. Here we denote profile as the complete attempt history of one task actually started in one seed's run, and tasks never reached by the router are excluded. At the largest MATH500 budget, unsolved profiles make up 3.25% of these recorded profiles but absorb 20.2% of spending. On GPQA, their share of spending is 53.9%. These figures show why neither low spending nor budget exhaustion alone measures allocation quality. EC.2.5 records the underlying utilization, profile counts, and per-task costs.
5.1.2 Choosing the Resolution Parameter K

Figure 3: K-sweep in Experiment 1.
Theorem 4.4 identifies the trade-off between resolution and precision but does not select an operating point. On live traffic the resolution sweep favors a coarse mesh. The sweep shows no clear gain beyond the compact used in Figure 2, and empirical coverage declines at the finest meshes. Two groups of new runs examine these outcomes. A sweep reruns the full policy at in four dataset-budget cells, changing only the resolution parameter , and a call-level audit compares the deployed bound with the charges it admitted. In the sweep (Figure 3), across-seed dispersion grows several-fold on MATH500 at the two finest meshes; a two-level bootstrap pooled over the four cells separates from and , but not from or . The audit checks the coverage of the deployed cost bounds. These runs reuse warm data and tune the confidence scales, so the audit does not verify the theorem's calibration assumptions. The observed fraction of calls satisfying declines monotonically in on both datasets, and on GPQA it falls below the operating target at . Provider variation and differences in routing history also affect these results. They support using a coarse mesh at the reported sample sizes, but do not isolate the estimation term or establish an optimal . EC.2.6 and EC.2.7 report the sweep design, cell-level counts, mean differences, and coverage audit.
5.1.3 Ablation Study
The ablation removes the retry gate and the pacing update, separately and together, at and with three seed indices per cell. The largest observed loss from removing the retry gate occurs at the tighter budget. At the no-gate variant solves about a third fewer MATH500 tasks and under half as many GPQA tasks as the full policy, whereas at the gaps narrow to 7.4 and 23.0 tasks. Freezing the pacing multiplier at its initial value costs little on MATH500 but 12.7 tasks on GPQA at the tight budget. The no-gate gap is smaller at the larger tested budget, while the loss associated with freezing pacing varies by dataset and budget. These comparisons describe sensitivity to component removal. Table 1 reports all cells and the seed protocol.
5.2 Experiment 2: Comparison on a Public Benchmark
We also compare on ROUTERBENCH [HBL 24], a public benchmark of 36,497 queries drawn from eight datasets and answered by eleven models under a single-call limit, with a standardized test stream, model costs, and a stored score in [0, 1] per query-model pair. ADP-HT runs against BA, PA, ParetoBandit, and budget-unaware Greedy LinUCB over five seeds, each on a stratified
Table 1: Ablation study solved counts. Budgets are in USD.
| Dataset | Budget | ADP-HT | Frozen- | No-gate | Frozen-+No-gate |
|---|---|---|---|---|---|
| MATH500 | 0.05 | 291.3 (±28.9) | 286.3 (±2.1) | 192.3 (±16.3) | 198.7 (±7.6) |
| 0.30 | 371.7 (±15.9) | 365.7 (±6.7) | 364.3 (±21.0) | 366.7 (±6.5) | |
| GPQA | 0.05 | 129.7 (±7.6) | 117.0 (±1.7) | 63.0 (±3.5) | 53.7 (±10.5) |
| 0.30 | 246.0 (±1.0) | 239.3 (±8.0) | 223.0 (±3.0) | 239.0 (±12.5) |
Mean over three seeds, ± one standard deviation.
20%/80% split, across fourteen budgets spanning 80.04. The outcome is the five-seed mean cumulative score of all tasks. Figure 4 plots it with the budgets ordered as categories, because the grid spans more than two orders of magnitude. ADP-HT leads all eight budgets through 5.336, reaching 9,827 at 1.50 against 6,982 for the nearest comparator and 1,283 for Greedy. It exceeds BA and ParetoBandit in every cell and leads all five protocols in ten of fourteen, with a largest deficit of 2.8% in the four remaining cells. EC.2.3 gives the configurations, the warm information available to each method, and the cell-level means.

Figure 4: Comparison on ROUTERBENCH.
We also conduct a cost-head ablation on ROUTERBENCH within a common reward learner and budget controller. K-Bit is the K-bit head implemented in ADP-HT. Continuous Mean uses the corresponding continuous output-length mean predictor. Mean-Adjusted adds a continuous-length confidence correction to Continuous Mean. K-Bit and Mean-Adjusted share the same tail-tolerance setting .
Table 2: Cost-head comparison on ROUTERBENCH.
| Budget (USD) | K-Bit | Continuous Mean | Mean-Adjusted |
|---|---|---|---|
| 5.00 | 15,989.4 (770.9) | 14,774.2 (768.9) | 15,502.3 (416.7) |
| 8.86 | 18,397.6 (462.3) | 16,923.7 (1,589.2) | 17,419.5 (1,048.8) |
| 10.00 | 18,673.3 (376.0) | 17,248.3 (1,359.2) | 17,446.2 (1,199.9) |
| 13.34 | 18,931.1 (515.2) | 17,851.0 (1,330.5) | 17,762.9 (1,310.1) |
| 20.00 | 18,996.2 (532.9) | 18,771.0 (883.9) | 18,668.4 (992.8) |
| 40.02 | 19,888.3 (315.2) | 20,072.6 (151.7) | 20,054.0 (188.7) |
| 80.04 | 20,272.6 (187.2) | 20,263.1 (195.8) | 20,283.6 (184.1) |
Entries are five-seed means with sample standard deviations. Bold indicates the highest mean at each budget.
Table 2 compares seven representative budgets over five runs with different seeds. K-Bit has the highest mean score at tight budgets, which shows the benefit of a discrete tail-safe predictor. And as the budget grows, all the three heads perform similarly, which is intuitive because the risk of exhausting the budget too early is lower. EC.3 reports the grid diagnostic and all paired intervals.
5.3 Experiment 3: Comparison with a Deployed Commercial Router
Experiment 3 compares ADP-HT with the OpenRouter AutoRouter service [Ope26b], using its recorded default and cost-saving configurations. We use LIVECODEBENCH [JHG+25] release_v6, with 844 test problems after a fixed-seed split reserves 211 for ADP-HT's warm start. Both routers share the frozen 39-model pool, problem order, one-call limit, and process-isolated execution grader, and use API-reported cost accounting.

Figure 5: Commercial-router comparison on the common 844-problem LIVECODEBENCH stream.
Against a commercial router, ADP-HT's advantage is concentrated where the budget binds, and there it is large. At the three lowest budgets, 0.404, and 22.86 in solved count and uses less test-time spend. Each AutoRouter curve is one complete pass truncated at the first budget crossing, so it cannot fall as $B grows, whereas every ADP-HT point is a separate live run whose learning path and provider responses differ from cell to cell even at temperature zero. With only one run per budget, this response and execution variability is not averaged out and influenced by the LLM service provider, so ADP-HT's counts may not rise monotonically.
At larger budgets, call failures complicate the comparison. Cost-saving AutoRouter issues all 844 calls for $1.62 and solves 732 problems, more than ADP-HT reaches at any of the four larger budgets and at lower realized spend. All four of those ADP-HT paths encounter provider-credit or relay-transport failures, reported in Table 6. We retain these calls as unsuccessful. The failures depress the recorded counts and prevent a clean comparison of routing performance at the larger budgets. This single-split study provides a snapshot of the two routers' performance on a shared stream, and highlights the importance of an adaptive and budget-aware routing policy. ADP-HT learns from its warm-start calls and keeps updating during service. The earlier AutoRouter service was described as using a pretrained router [Not26], whose training-data size was not disclosed but can be expected to be large. This also uncovers another advantage of ADP-HT, which can learn online and dynamically even after deployment, whereas a pretrained router cannot.
6 Conclusion
We study LLM routing as an online allocation problem in which a call's cost is learned only after the budget has been committed. Under a halt-after-crossing budget, an admission decision affects both the current task and every later task the remaining budget could have served, so controlling spending in expectation does not control that exposure. We formulate the problem as K-bit Pathwise Contextual Bandits with Knapsacks. Exact charges accumulate in the ledger, while the cost learner observes only which of response-length intervals a call landed in. ADP-HT turns those labels into a one-sided pre-call cost bound and prices it by the current shadow value of capacity, so one score governs both model choice and retries. The analysis gives a conditional K-bit trade-off for the implemented quantile mesh. More bits reduce core discretization but increase the allowance for simultaneous estimation, with an additional term for edge-placement error. A matching construction establishes the tightness of the two K-dependent terms under the stated confidence calibration. This bound motivates choosing resolution to match the available sample size. Under the protocols we report, the gains concentrate where the budget determines which tasks are reached. At the tightest tested budgets ADP-HT completes more than twice as many MATH500 and GPQA tasks as the best implemented comparator, leads ten of fourteen ROUTERBENCH budgets, and outperforms a deployed commercial router at the three lowest test budgets.
Future work. Several directions remain open. First, extending pathwise budget control to open-ended work such as writing, analysis, and code review would require modeling the uncertainty of a learned judge and its rubric-based evaluations. The resolution-estimation trade-off could then appear in the grading mesh as well as the length mesh, which makes that setting a natural test of how far the mechanism travels. Second, a joint treatment of selection, pricing, pacing, and retries would bring the dual path inside the guarantee and deliver an end-to-end pathwise statement. Lower bounds over routing policies would clarify how much additional service can be gained from finer cost information. Third, sharper response-length prediction is an immediately practical lever. Any predictor that localizes the conditional tail more tightly shrinks the estimation radius at a fixed resolution, so the same mesh admits a tighter bound, and the mechanism composes with advances made elsewhere. Fourth, an adaptive mesh that re-places its edges and reset K as the workload drifts, would make the resolution parameter K and edge positions a control component that the operator can tune during service rather than a constant fixed at warm start.
References
[Ach03] Dimitris Achlioptas. Database-friendly random projections: Johnson-lindenstrauss with binary coins. Journal of Computer and System Sciences, 66(4):671–687, 2003.
[AD16] Shipra Agrawal and Nikhil R. Devanur. Linear contextual bandits with knapsacks. In Advances in Neural Information Processing Systems, volume 29, 2016.
[AMA 24] Pranjal Aggarwal, Aman Madaan, Ankit Anand, Srividya Pranavi Potharaju, Swaroop Mishra, Pei Zhou, Aditya Gupta, Dheeraj Rajagopal, Karthik Kappaganthu, Yiming Yang, Shyam Upadhyay, Manaal Faruqui, and Mausam. AutoMix: Automatically mixing language models. In Advances in Neural Information Processing Systems, volume 37, pages 131000–131034, 2024.
[Ant26] Anthropic. Pricing. https://platform.claude.com/docs/en/about-claude/pricing, 2026. Accessed 2026-10-28.
[ATM23] Siddharth Arora, James W. Taylor, and Ho-Yin Mak. Probabilistic forecasting of patient waiting times in an emergency department. Manufacturing & Service Operations Management, 25(4):1489–1508, 2023.
[AYPS11] Yasin Abbasi-Yadkori, Dávid Pál, and Csaba Szepesvári. Improved algorithms for linear stochastic bandits. In Advances in Neural Information Processing Systems, volume 24, pages 2312–2320, 2011.
[BCW26] Alexandre Belloni, Yan Chen, and Yehua Wei. Online pandora's box for contextual LLM cascading. arXiv preprint arXiv:2606.07392, 2026.
[Bei23] Beijing Academy of Artificial Intelligence. BAAI/bge-small-en-v1.5 model card. https://huggingface.co/BAAI/bge-small-en-v1.5, 2023. Accessed 2026-10-28.
[BKS18] Ashwinkumar Badanidiyuru, Robert Kleinberg, and Aleksandrs Slivkins. Bandits with knapsacks. Journal of the ACM, 65(3):13:1–13:55, 2018.
[BLM23] Santiago R. Balseiro, Haihao Lu, and Vahab Mirrokni. The best of many worlds: Dual mirror descent for online allocation problems. Operations Research, 71(1):101–119, 2023.
[BSL26] Seoungbin Bae, Junyoung Son, and Dabeen Lee. Learning to route and schedule LLMs from user retrials via contextual queueing bandits. arXiv preprint arXiv:2602.02061, 2026.
[BTZ26] Jinzhi Bu, Haixin Tang, and Huanan Zhang. OR for AI that does OR: Routing LLMs up the escalator inside the OSCAR framework. SSRN working paper 7541118, September 2026. Also available as arXiv:2610.00912.
[CES20] Semih Cayci, Atilla Eryilmaz, and R. Srikant. Budget-constrained bandits over general cost and reward distributions. In Proceedings of the Twenty Third International Conference on Artificial Intelligence and Statistics, volume 108 of Proceedings of Machine Learning Research, pages 4388–4398. PMLR, 2020.
[CKMZ19] Maxime C. Cohen, Philipp W. Keller, Vahab Mirrokni, and Morteza Zadimoghaddam. Overcommitment in cloud services: Bin packing with chance constraints. Management Science, 65(7):3255–3271, 2019.
[CZZ24] Lingjiao Chen, Matei Zaharia, and James Zou. FrugalGPT: How to use large language models while reducing cost and improving performance. Transactions on Machine Learning Research, 2024.
[DBV25] Jasper Dekoninck, Maximilian Baader, and Martin Vechev. A unified approach to routing and cascading for LLMs. In Proceedings of the 42nd International Conference on Machine Learning, volume 267 of Proceedings of Machine Learning Research, pages 12987–13010. PMLR, 2025.
[DMW+24] Dujian Ding, Ankur Mallick, Chi Wang, Robert Sim, Subhabrata Mukherjee, Victor Rühle, Laks V. S. Lakshmanan, and Ahmed Hassan Awadallah. Hybrid LLM: Cost-efficient and quality-aware query routing. In The Twelfth International Conference on Learning Representations, 2024.
[Git26] GitHub. Usage-based billing for organizations and enterprises. https://docs.github.com/en/copilot/concepts/billing-and-usage/organizations-and-enterprises/billing, 2026. Accessed 2026-10-28.
[Has20] Trevor Hastie. Ridge regularization: An essential concept in data science. Technometrics, 62(4):426–433, 2020.
[HBK+21] Dan Hendrycks, Collin Burns, Saurav Kadavath, Akul Arora, Steven Basart, Eric Tang, Dawn Song, and Jacob Steinhardt. Measuring mathematical problem solving with the MATH dataset. In Proceedings of the Neural Information Processing Systems Track on Datasets and Benchmarks, volume 1, 2021.
[HBL 24] Qitian Jason Hu, Jacob Bieker, Xiuyu Li, Nan Jiang, Benjamin Keigwin, Gaurav Ranganath, Kurt Keutzer, and Shriyash Kaustubh Upadhyay. RouterBench: A benchmark for multi-LLM routing system. arXiv preprint arXiv:2403.12031, 2024.
[HR22] Steven R. Howard and Aaditya Ramdas. Sequential estimation of quantiles with applications to a/b testing and best-arm identification. Bernoulli, 28(3):1704–1728, 2022.
[HYF22] Osama A. Hanna, Lin Yang, and Christina Fragouli. Solving multi-arm bandit using a few bits of communication. In Proceedings of The 25th International Conference on Artificial Intelligence and Statistics, volume 151 of Proceedings of Machine Learning Research, pages 11215–11236. PMLR, 2022.
[JHG 25] Naman Jain, King Han, Alex Gu, Wen-Ding Li, Fanjia Yan, Tianjun Zhang, Sida I. Wang, Armando Solar-Lezama, Koushik Sen, and Ion Stoica. LiveCodeBench: Holistic and contamination free evaluation of large language models for code. In The Thirteenth International Conference on Learning Representations, 2025.
[JSS22] Huiwen Jia, Cong Shi, and Siqian Shen. Online learning and pricing with reusable resources: Linear bandits with sub-exponential rewards. In Proceedings of the 39th International Conference on Machine Learning, volume 162 of Proceedings of Machine Learning Research, pages 10135–10160. PMLR, 2022.
[LCLS10] Lihong Li, Wei Chu, John Langford, and Robert E. Schapire. A contextual-bandit approach to personalized news article recommendation. In Proceedings of the 19th International Conference on World Wide Web, pages 661–670, 2010.
[LHZN26] Philippe Laban, Hiroaki Hayashi, Yingbo Zhou, and Jennifer Neville. LLMs get lost in multi-turn conversation. In C. Vondrick, B. Hariharan, C. Raffel, L. Pinto, D. Yang, and A. Faust, editors, International Conference on Learning Representations, volume 2026, pages 54738–54778, 2026.
[LLL 26] Guokai Li, Alys Liang, Mo Liu, Murray Lei, Stefanus Jasin, Fenghua Yang, and Preet Baxi. Sequential sampling for binary classification: Two LLMs are (almost) all you need. arXiv preprint arXiv:2604.01086, 2026.
[LLSY21] Xin Liu, Bin Li, Pengyi Shi, and Lei Ying. An efficient pessimistic-optimistic algorithm for stochastic linear bandits with general constraints. In Advances in Neural Information Processing Systems, volume 34, 2021.
[LNSZ21] Mengshi Lu, Hideaki Nakao, Siqian Shen, and Lin Zhao. Non-profit resource allocation and service scheduling with cross-subsidization and uncertain resource consumptions. Omega, 99:102191, 2021.
[LS25] Ivan Lau and Jonathan Scarlett. Quantile multi-armed bandits with 1-bit feedback. In Proceedings of the 36th International Conference on Algorithmic Learning Theory, volume 272 of Proceedings of Machine Learning Research, pages 664–699. PMLR, 2025.
[Mas90] Pascal Massart. The tight constant in the Dvoretzky–Kiefer–Wolfowitz inequality. The Annals of Probability, 18(3):1269–1283, 1990.
[Not26] Not Diamond. What is model routing? https://docs.notdiamond.ai/docs/what-is-model-routing, 2026. Accessed 2026-10-28.
[OAW+25] Isaac Ong, Amjad Almahairi, Vincent Wu, Wei-Lin Chiang, Tianhao Wu, Joseph E. Gonzalez, M. Waleed Kadous, and Ion Stoica. RouteLLM: Learning to route LLMs from preference data. In The Thirteenth International Conference on Learning Representations, 2025.
[Ope26a] OpenAI. GPT-5.6 Sol. https://developers.openai.com/api/docs/models/gpt-5.6-sol, 2026. Accessed 2026-10-28.
[Ope26b] OpenRouter. Auto router. https://openrouter.ai/docs/guides/routing/routers/auto-router, 2026. Accessed 2026-10-28.
[Ope26c] OpenRouter. Models. https://openrouter.ai/docs/guides/overview/models, 2026. Accessed 2026-10-28.
[Ope26d] OpenRouter. Pricing. https://openrouter.ai/pricing, 2026. Accessed 2026-10-28.
[PDL+26] Manhin Poon, Xiangxiang Dai, Xutong Liu, Fang Kong, John C. S. Lui, and Jin-hang Zuo. Online multi-LLM selection via contextual bandits under unstructured context evolution. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 40, pages 24855–24863, 2026.
[PLMTB23] Aleksandar Petrov, Emanuele La Malfa, Philip H. S. Torr, and Adel Bibi. Language model tokenizers introduce unfairness between languages. In Advances in Neural Information Processing Systems, volume 36, pages 36963–36990, 2023.
[PMD+25] Pranoy Panda, Raghav Magazine, Chaitanya Devaguptapu, Sho Takemori, and Vishal Sharma. Adaptive LLM routing under budget constraints. In Findings of the Association for Computational Linguistics: EMNLP 2025, pages 23934–23949, Suzhou, China, November 2025. Association for Computational Linguistics.
[PVG+21] Filipo Studzinski Perotto, Sattar Vakili, Pratik Gajane, Yaser Faghan, and Mathieu Bourgais. Gambler bandits and the regret of being ruined. In Proceedings of the 20th International Conference on Autonomous Agents and Multiagent Systems, pages 1664–1667, 2021. Extended abstract.
[RHS+24a] David Rein, Betty Li Hou, Asa Cooper Stickland, Jackson Petty, Richard Yuanzhe Pang, Julien Dirani, Julian Michael, and Samuel R. Bowman. GPQA: A graduate-level google-proof Q&A benchmark. In First Conference on Language Modeling, 2024.
[RHS24b] Charles Riou, Junya Honda, and Masashi Sugiyama. The survival bandit problem. Transactions on Machine Learning Research, 2024.
[SPdO+26] Seamus Somerset, Felipe Maia Polo, Allysson Flavio Melo de Oliveira, Prattyush Mangal, Mírian Silva, Onkar Bhardwaj, Mikhail Yurochkin, and Subha Maity. CARROT: A cost aware rate optimal router. The Annals of Applied Statistics, 2026. Accepted for publication; to appear.
[SZSF24] Aleksandrs Slivkins, Xingyu Zhou, Karthik Abinav Sankararaman, and Dylan J. Foster. Contextual bandits with packing and covering constraints: A modular Lagrangian approach via regression. Journal of Machine Learning Research, 25(394):1–37, 2024.
[TDSY26] Jingwen Tang, Izak Duenyas, Cong Shi, and Nan Yang. Multiproduct inventory systems with upgrading: Replenishment, allocation, and online learning. Manufacturing & Service Operations Management, 28(2):537–557, 2026.
[TM26] Annette Taberner-Miller. ParetoBandit: Budget-paced adaptive routing for non-stationary LLM serving. arXiv preprint arXiv:2604.00136, 2026.
[Top09] Huseyin Topaloglu. Using lagrangian relaxation to compute capacity-dependent bid prices in network revenue management. Operations Research, 57(3):637–649, 2009.
[TTCRJ12] Long Tran-Thanh, Archie Chapman, Alex Rogers, and Nicholas R. Jennings. Knapsack based optimal policies for budget-limited multi-armed bandits. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 26, pages 1134–1140. AAAI Press, 2012.
[TvR98] Kalyan Talluri and Garrett van Ryzin. An analysis of bid-price controls for network revenue management. Management Science, 44(11-part-1):1577–1593, 1998.
[WQX 26] Jing Wang, Yu-Yang Qian, Ke Xue, Chao Qian, Peng Zhao, and Zhi-Hua Zhou. Robust length prediction: A perspective from heavy-tailed prompt-conditioned distributions. arXiv preprint arXiv:2604.07931, 2026.
[WSLS16] Yifan Wu, Roshan Shariff, Tor Lattimore, and Csaba Szepesvári. Conservative bandits. In Proceedings of The 33rd International Conference on Machine Learning, volume 48 of Proceedings of Machine Learning Research, pages 1254–1262. PMLR, 2016.
[XZW26] Zhongling Xu, Shunan Zheng, and Wei Wang. SeqRoute: Global budget-aware sequential LLM routing via offline reinforcement learning. arXiv preprint arXiv:2605.25424, 2026.
[ZKSV22] Mohammad Zhalechian, Esmaeil Keyvanshokooh, Cong Shi, and Mark P. Van Oyen. Online resource allocation with personalized learning. Operations Research, 70(4):2138–2161, 2022.
[ZLW 26] Yiqun Zhang, Hao Li, Zihan Wang, Shi Feng, Xiaocui Yang, Daling Wang, Bo Zhang, Lei Bai, and Shuyue Hu. MTRouter: Cost-aware multi-turn LLM routing with history-model joint embeddings. In Proceedings of the 64th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 44206–44226, San Diego, California, United States, July 2026. Association for Computational Linguistics.
[ZO21] Mengyan Zhang and Cheng Soon Ong. Quantile bandits for best arms identification. In Proceedings of the 38th International Conference on Machine Learning, volume 139 of Proceedings of Machine Learning Research, pages 12513–12523. PMLR, 2021.
EC.1 Proof and Calibration Details
We prove (17) and derive its model-selection implication. We then give statistical conditions for the estimation bound, show that both error terms can attain the stated orders, and extend the result to other grids.
EC.1.1 Formal Cost-Bound Theorem
Fix , suppress the feature arguments, and write . For tail tolerance , define
Let denote (11). We study the excess . If is finite, right-continuity ensures .
At grid edges, by (7). Let and be the bound and selected length from (9)–(10).
For integer , the frozen mesh has intervals, with core intervals and one tail interval. A nondecreasing reference curve assigns core-edge reference locations and need not describe the current length distribution. Require , , and
Here bounds finalized edge error in tokens from warm-data estimation, integer lengths, and repeated-edge adjustments, without an assumed sampling rate.
Define the maximum actual core spacing and reference spacing . Equation (19) gives
For with independent of , sufficient placement conditions are
where and are fixed across grids. These follow from . Exact placement permits . The full bound retains without either spacing condition.
Let bound the excess of every reported probability bound. All threshold heads share warm () and earlier online fitting calls in (35), excluding separate grid-placement pilot data under EC.1.3. Require
The constants are independent of . Here collects feature, fitting-horizon, and confidence parameters, while accounts for simultaneous confidence across thresholds. EC.1.3 gives a calibration.
To translate probability error into a length allowance, let denote tokens added to . In addition to the grid and estimation conditions above, assume that there are constants satisfying
Here bounds the probability margin per added token from below over the range . The last two inequalities keep the length allowance within this range and the core. The bound below holds at every history satisfying the grid, estimation, and margin conditions. It retains and . The simplified rate also requires core spacing to decrease as and to remain fixed.
The local margin condition (23) in Theorem 1 does not require a continuous response-length distribution. It holds, for example, if is absolutely continuous on and almost everywhere on that interval. Since , integration gives . The length allowance must still satisfy (24).
Theorem 1 (K-bit cost-bound trade-off). At a pre-call pair , use the grid and notation above with , finite , input charge known at , and . Construct the bounds and selected edge by (9)–(11), replacing only the fallback in (10) by an empirical top edge when applicable. Assume the following conditions hold at this history.
(i) The finalized core grid satisfies (19).
(ii) All reported bounds satisfy (21)–(22).
(iii) The conditional tail and core coverage satisfy (23)–(24).
A core edge passes the first-safe-edge test, and
(25)
For the potential call cost , the same history satisfies
If, in addition, and , and are fixed independently of and , then
Thus (17) holds uniformly over the pairs satisfying these conditions, with a constant independent of and .
EC.1.2 Proof and Model Selection
Proof of Theorem 1. Write and . For each finalized core interval, (19) gives
Set and take the first core edge , which exists by (24). Then , also for since . Monotonicity and (23) give and . Thus qualifies and coverage yields , so
The input charge cancels. Multiplying by and substituting (22) proves (25). For (27), substitute and in (25). Equation (20) supplies sufficient . The implicit constant can be , independent of under the fixed-parameter conditions. The calibration below requires fixed , feature and regularization parameters, and confidence level. If grows with , retain as in (25). Cost exceeds its bound exactly when output length exceeds the selected edge, giving (26). A qualifying core edge avoids any need for a support bound at .
At an executed step with controller values and , define
(29)
For selected by (15b), let denote (25). If the theorem holds for and both reward estimates satisfy , then
(30)
Put , , and . For both arms, clipping and reward confidence give , and the theorem gives . Maximization of yields
This proves (30).
EC.1.3 Statistical Conditions for the Estimation Bound
Fix a deterministic fitting-call bound per model and . The following bounds hold on one event of probability at least over fitting data.
Fix a deterministic mesh before collecting fitting data, or construct it from separate pilot data and condition all assumptions on those data. Exclude pilot data from fits. At every warm or online fitting call, model choice and cost feature must be known before the response, but may depend on earlier responses. For each , a fixed coefficient applies to fitting and prediction, with , and . Extend to warm calls, including separate pilot data in the initial information. For every fitting call to model , threshold , and , require
All conditions include warm observations. Binary labels permit . Let denote ridge regularization, the design in (35), and the identity.
Apply the self-normalized ridge bound of [AYPS11] to each head with failure probability . The bound is simultaneous over fitting times and therefore permits adaptive model choices. The determinant bound
and a union bound over heads, requiring no independence between them, give the simultaneous prediction bounds
Set , write , and abbreviate the clipped bound before monotone projection as . On this event, (8) gives . For , . The cumulative minimum therefore preserves coverage and can only reduce the excess at edge .
If the smallest eigenvalue satisfies at every step considered, for fixed , a valid calibration in (22) is
(33)
Substitution in (31) gives since . Combining this with and the eigenvalue bound gives
The factor 2 covers prediction error and confidence bonus. For fixed , the theorem therefore holds on this event at all pairs with satisfying its grid, margin, core, and design conditions. Here controls estimation, whereas bounds the next call's conditional tail probability. For finitely many candidate values, split failure probability equally across them and add their log count to .
EC.1.4 Order Tightness
The following exact-core construction ( ) attains both K-dependent orders in (25) under the stated calibration.
Proposition 1 (Order tightness). Fix and integers , with confidence parameter and finite-sample failure probability . The parameter enters the confidence radius used by the algorithm, whereas controls the probability of the empirical-cdf event on which the finite-sample conclusion below holds. At horizon , take independent normalized lengths () from one model, constant feature , unit ridge regularization, , and
Set , , , core edges (), and . After observations, abbreviate the first-safe-edge length and cost by , . The target is , with cost from (18). For price , .
The calibration uses , , and . Equation (33) gives , , and the allowance and empirical-distribution radius
If and , then with probability at least , Theorem 1(i)-(iii) hold with , , , , and
For fixed and , take with and . Then , , and , where denotes convergence in probability.
The comparison and , , show that (34) matches both orders in (25). This result retains because grows and applies only to the stated calibration.
Proof of Proposition 1. The scalar model has on , with , conditionally -sub-Gaussian centered Bernoulli noise, and design . The curve gives and . Since for , we also have and .
Write , ridge bonus , shrinkage , and . Equation (33) gives , so . Let be the empirical cdf, , and . The Dvoretzky-Kiefer-Wolfowitz inequality [Mas90] gives . Since and , on the excess before clipping satisfies
Clipping to preserves coverage and excess. The clipped bounds are nonincreasing in , so the cumulative minimum leaves them unchanged. Hence . Also gives and , verifying Theorem 1(i)–(iii) on .
The safe-edge test requires , where . Thus on , the selected edge satisfies
Also, , so every grid edge strictly above is at least above it. Hence . For the upper bound, the first core edge at or above lies within and has reported bound at most . It qualifies, giving . Cancelling input charge and multiplying by proves (34) on .
Set and . The test is . Since , we have and . Thus, for and the th order statistic , almost surely. Also,
Hence . Under fixed , , and , we have , , and . With probability tending to one, , so its next edge is in the core and almost surely. Thus . Divide by and use for the claimed limit. For fixed , the finite-sample conditions eventually hold since and .
EC.1.5 Grid Conditions and Extension
A density bounded below by throughout the reference core support gives -Lipschitz quantiles. To compare grids across , fix the state, sample size, and , and require each grid to satisfy the theorem. The placement error may vary, but the two-term rate requires common . Separate routing runs may use different data.
For fixed , write and . A frozen, strictly increasing grid has upward rounding distance on . The same proof under (21) and (23) gives, if and ,
Equal-width grids give . Quantile meshes can have large tail rounding errors, so their core-resolution rate requires in the core.
The experiments reuse warm data for placement and fitting, tune , and use an empirical top edge. Because these choices need not satisfy the calibration assumptions, we measure coverage directly in EC.2.7.
EC.2 Implementation and Evaluation Details
EC.2.1 Learners, Frozen Mesh, and Parameters
We use normalized BGE-small-en-v1.5 embeddings and seed-specific QR for projection in Section 4.1. The cost feature has dimension . Its ten pre-call components are retry fraction, retry-depth fraction, current-task-spend ratio, remaining-budget ratio, log input-token scale, candidate-arm price scale, previous-arm price scale, previous reward, previous-cost scale, and a same-as-previous-arm indicator.
Ridge learners. Fitting includes warm calls and online calls before . The reward feature , , places in model 's block. With ridge penalties and identity matrix ,
In (5), and are the first entries and subsequent model blocks of . We use variance proxy and Schur complements with . Cost heads share a design matrix with threshold-specific feature-label vectors,
(35)
Writing , their estimates and common variance proxy are
Warm mesh. Experiment 1 uses unconstrained Greedy LinUCB warm logs, fixes during replay, and rebuilds cost heads on the finalized grid. Let the multiset contain warm completion-token counts (estimated from cost if unavailable) and be the empirical -quantile. With one tail and core intervals, set , where for MATH500 and 0.75 for GPQA. For , place for , with and . Replace each nonincreasing edge by its predecessor plus , which can move slightly above the target . The top edge is
Below warm samples, we use a geometric core grid. All reported runs permit quantile placement. Length labels use bits, while the ledger, controller, and features retain exact charges and prior outcomes.
Execution details. Score ties favor reward UCB, then the smaller mean-cost proxy. For fixed , let and . The left-edge approximation to the survival integral on gives
We follow Algorithm 1 with pacing after four samples and stopping rule (2). Spending discrepancies in (14a) and (14b) are clipped to , and exponents to . Neither limit binds. Table 3 gives dataset-specific settings, with “init” denoting initial online values. Budget-aware (BA) and Position-aware (PA) LinUCB share parameters.
Table 3: Experiment 1 implementation settings.
| Setting | MATH500 | GPQA |
|---|---|---|
| Seeds, warm/test split | 42–46, 20%/80% | 42–46, 20%/80% |
| Warm-start, retry upper bound | Greedy infinite-budget replay, | Greedy infinite-budget replay, |
| Embedding and grader | BGE-small-en-v1.5, GPT-OSS-120B | BGE-small-en-v1.5, GPT-OSS-120B |
| Arms | Qwen3-8B, Phi-4, Gemini-Flash-Lite, DeepSeek-V3.2, GPT-5-mini | |
| Budgets (USD) | 0.025, 0.05, 0.075, 0.125, 0.30, 0.45, 0.60 | MATH grid plus 0.80, 1.00 |
| , mesh edges, | 2, warm-start quantiles, 8 | 2, warm-start quantiles, 8 |
| Core coverage quantile | 0.95 | 0.75 |
| 0.25, 0.35, 0.10 | 0.35, 0.18, 0.24 | |
| 0.25, 8.0, 0.05 | 0.50, 12.0, 0.08 | |
| 1.0, [0.5, 3.0], 0.12 | 0.80, [0.35, 2.5], 0.10 | |
| 0.02, 0.10, 0.50 | 0.03, 0.12, 0.65 |
EC.2.2 Experiment 1 Protocol and Baselines
Stratified 20%/80% splits give 100/400 warm/test problems for MATH500 and 90/358 for GPQA. Policies share warm logs, task order, prompts, GPT-OSS-120B verifier, local BGE embeddings [Bei23], model menu, retry limit, and ledger. Tables 3 and 4 give seeds, budgets, and token prices.
Calls use one user message and no system prompt [PDL+26]. The first-call template is
Solve the following problem: {question} Please answer in a short, clear, and concise way. Show only the essential derivation, and end with the final answer in LaTeX format, enclosed within \boxed{}. For example: 'The final answer is \boxed{x}'.
After failure, we retain the question and append failed attempts in order.
The previous attempts below were incorrect. Please answer the problem again with the same short, clear, ↔ and concise style.
- Attempt 1 (by {model_id_1}): {failed_response_1}
- Attempt 2 (by {model_id_2}): {failed_response_2} ...
Now please provide your new answer based on the above attempts and the original question.
The grader sees only candidate and reference answers. Reward is one exactly when its whitespace-stripped output is True.
Expression 1: {model_answer} Expression 2: {ground_truth_answer}
Expression 2 is the answer and expression 1 is attempt by student. Look at their final answer only, which ↔ might be boxed. Does the student get the final expected answer? Respond with only the word 'True' ↔ or 'False'.
Implemented baselines. LinUCB baselines fit rewards by arm. Greedy selects by reward UCB, and its unconstrained trajectory is replayed under (2). BA admits arms whose empirical mean cost plus one standard deviation fits , then ranks reward UCB divided by a cost lower confidence bound. PA solves a 0–1 knapsack with these cost estimates and reward UCBs, choosing the highest reward-UCB feasible arm. Both use exploration scale 0.675, cost coefficient 1.0, and ridge penalty 0.45 on both datasets [PDL⁺26].
ParetoBandit [TM26] uses exploration scale , variance-inflation cap , geometric forgetting , static cost weight , adaptive dual cap , dual step , EMA coefficient 0.05, cost floor , no forced initial pulls, and finite-stream average-cost target . Preference and cascade routers lack this replay protocol and appear as related systems.
Table 4: Model identifiers and configured token prices (USD/token).
| Model | Input price | Output price |
|---|---|---|
| qwen/qwen3-8b | ||
| microsoft/phi-4 | ||
| google/gemini-2.5-flash-lite | ||
| deepseek/deepseek-v3.2 | ||
| openai/gpt-5-mini |
EC.2.3 RouterBench Protocol and Configurations
ROUTERBENCH has 36,497 prompts and eleven models, with scores in [0,1] (78.9% binary). Seeds 42–46 give task-stratified 20%/80% warm/test splits of approximately 7,298/29,199 prompts. We set , reveal each selected outcome, and charge its stored cost under the common crossing rule. Cumulative score sums outcomes until stopping. Completion length is estimated as from stored responses. Input token price is zero. Output token price is each model's median cost divided by its median proxy length.
All five policies share Greedy chosen-arm warm logs, splits, test order, and ledger across budgets, with baselines from EC.2.2. Table 5 reports five-seed means to one decimal.
EC.2.4 Commercial-Router Protocol
The seed-42 split of 1,055 LIVECODEBENCH release_v6 problems gives 211 warm and 844 test problems. An isolated grader requires all public and private tests to pass. Requests use
Table 5: RouterBench cumulative scores, with five-seed means and budgets in USD.
| Budget | ADP-HT | BA | PA | ParetoBandit | Greedy |
|---|---|---|---|---|---|
| 0.500 | 2,745.2 | 2,083.4 | 2,192.2 | 1,714.7 | 330.8 |
| 1.000 | 5,616.6 | 4,120.2 | 4,720.7 | 2,564.3 | 1,137.2 |
| 1.500 | 9,827.2 | 6,601.7 | 6,982.4 | 3,389.5 | 1,283.0 |
| 2.000 | 11,142.8 | 8,234.4 | 8,664.6 | 4,242.6 | 1,361.9 |
| 2.500 | 12,157.7 | 9,309.8 | 9,891.7 | 5,992.2 | 1,545.0 |
| 3.500 | 13,731.9 | 13,375.3 | 13,586.9 | 9,041.4 | 1,857.7 |
| 4.400 | 14,737.0 | 13,013.4 | 14,423.9 | 12,794.8 | 1,988.4 |
| 5.336 | 15,323.9 | 13,330.8 | 14,831.2 | 14,292.5 | 2,116.2 |
| 7.000 | 16,815.8 | 13,677.8 | 17,293.8 | 14,727.4 | 2,347.0 |
| 8.858 | 17,702.6 | 14,135.3 | 18,122.0 | 15,030.9 | 2,608.7 |
| 13.340 | 18,496.9 | 14,814.1 | 18,295.6 | 15,390.6 | 3,197.4 |
| 26.681 | 18,718.4 | 14,667.8 | 18,813.8 | 15,771.6 | 4,892.3 |
| 53.361 | 20,101.2 | 15,100.8 | 19,229.2 | 15,847.6 | 19,534.0 |
| 80.042 | 20,200.2 | 15,020.0 | 19,463.6 | 15,893.2 | 20,340.7 |
temperature zero, one call per problem, and no output-token cap. All routers use the same 39 candidates from July 1, 2026 without output-cap filtering.
Default and cost-saving AutoRouter use cost_quality_tradeoff 7 and 10, respectively. Each full pass is reordered to the common sequence and replayed under (2) at every budget. Each ADP-HT budget has a separate live run.
Table 6 counts ADP-HT errors as unsolved with zero reported charge. Default AutoRouter solves 623 for 1.62 (seven errors, 14 flags). Auto-CS and Auto-default denote these settings, with default spending in parentheses. Frequent errors complicate comparison at larger budgets.
Table 6: Commercial comparison on the common 844-problem LIVECODEBENCH order.
| Nominal $B | ADP-HT solved | ADP-HT spend | Errors | Auto-CS solved | Auto-CS spend | Auto-default (spend) |
|---|---|---|---|---|---|---|
| 0.202 | 244 | 0.2024 | 0 | 86 | 0.2020 | 8 (0.5013) |
| 0.404 | 436 | 0.4041 | 0 | 166 | 0.4116 | 8 (0.5013) |
| 0.8081 | 682 | 0.8084 | 0 | 372 | 0.8092 | 15 (0.8190) |
| 5.710 | 704 | 5.7103 | 1 | 732 | 1.6161 | 154 (5.7851) |
| 11.430 | 628 | 7.4154 | 137 | 732 | 1.6161 | 298 (11.4701) |
| 17.140 | 710 | 15.5118 | 36 | 732 | 1.6161 | 420 (17.3688) |
| 22.860 | 615 | 10.7744 | 137 | 732 | 1.6161 | 623 (22.8551) |
EC.2.5 Experiment 1 Results and Uncertainty
Table 7 gives five-seed means and sample standard deviations for Figure 2. B-aware, P-aware, and Pareto denote BA, PA, and ParetoBandit. Gap is ADP-HT's mean minus the best of these baseline means. The plotted 95% intervals use 10,000 bootstrap resamples with a deterministic hash seed. Budgets share warm logs, making outcomes dependent.
Table 8 reports mean differences in solved counts, with equal weight on each budget in the fixed grid. For each dataset, we construct approximate paired 95% two-level bootstrap confidence intervals. Each draw first resamples budget cells with replacement and then resamples the five seed-level policy pairs within each drawn budget, keeping ADP-HT and the comparator aligned on the same seed. The statistic is the equally weighted mean difference over the fixed budget grid. The comparisons also reflect implementation and tuning differences.
Table 9 describes spending. Utilization averages spending/budget on MATH500. Profiles pool five ADP-HT runs at the largest budget, one per task/replicate. Unsolved is their unsolved fraction, and Unsolved spend is those tasks' spending share. Mean costs separate solved and unsolved tasks. Unsolved tasks cost more in both datasets, motivating control of retry spending.
Table 7: Experiment 1 solved counts (mean ± sample standard deviation over five seeds). Budgets are in USD.
| Dataset | Budget | Greedy | B-aware | P-aware | Pareto | ADP-HT | Gap |
|---|---|---|---|---|---|---|---|
| MATH500 | 0.025 | 115.4 | |||||
| 0.050 | 64.4 | ||||||
| 0.075 | 37.0 | ||||||
| 0.125 | 9.4 | ||||||
| 0.300 | 0.6 | ||||||
| 0.450 | 5.0 | ||||||
| 0.600 | 2.6 | ||||||
| GPQA | 0.025 | 55.2 | |||||
| 0.050 | 74.8 | ||||||
| 0.075 | 54.2 | ||||||
| 0.125 | 33.4 | ||||||
| 0.300 | 6.8 | ||||||
| 0.450 | 5.4 | ||||||
| 0.600 | 3.2 | ||||||
| 0.800 | 2.6 | ||||||
| 1.000 | 4.6 |
Table 8: Experiment 1 hierarchical-bootstrap gaps over each dataset's budget grid.
| Dataset | Baseline | Mean diff. | 95% CI | p-value (one-sided) |
|---|---|---|---|---|
| GPQA | Budget-aware | 40.3 | [27.4, 54.2] | |
| GPQA | Position-aware | 37.4 | [19.6, 54.2] | |
| GPQA | ParetoBandit | 27.9 | [11.3, 46.3] | |
| MATH500 | Budget-aware | 51.1 | [31.5, 80.4] | |
| MATH500 | Position-aware | 35.4 | [7.1, 71.3] | 0.001 |
| MATH500 | ParetoBandit | 44.8 | [8.1, 88.2] | 0.002 |
Table 9: Experiment 1 operational-path summaries from the five-seed main-frontier runs.
| Panel A, mean budget utilization on MATH500 (%) | ||||
|---|---|---|---|---|
| Policy | ADP-HT | BA | PA | ParetoBandit |
| Realized spend / nominal budget | 93.4 | 75.7 | 77.2 | 81.5 |
| Panel B, maximum-budget task profiles for ADP-HT | ||||
| Dataset () | Profiles | Unsolved (%) | Unsolved spend (%) | Mean cost, solved / unsolved |
| MATH500 (0.60) | 2,000 | 3.25 | 20.2 | 0.926/6.989 |
| GPQA (1.00) | 1,784 | 24.72 | 53.9 | 1.331/4.732 |
Mean task costs in Panel B are in USD.
EC.2.6 Resolution Sweep
We vary on both datasets at , with five replicates per setting. Each replicate shares warm lengths and the protocol of EC.2.2 across . These runs are separate from the main frontier. Default predates this analysis.
Table 10 reports solved counts (Panel A) and paired two-level bootstrap with equal-weight settings (Panel B). Intervals favor over but include zero against . Provider variation and routing history also affect outcomes, so this does not establish an optimal or verify the theorem's assumptions.
Table 10: Resolution sweep with five-seed solved counts (mean ± sample standard deviation) and pooled two-level bootstrap comparisons. Budgets are in USD.
Panel A. Cell-level solved counts
| Dataset | Budget | |||||
|---|---|---|---|---|---|---|
| MATH500 | 0.05 | |||||
| MATH500 | 0.3 | |||||
| GPQA | 0.05 | |||||
| GPQA | 0.3 |
Panel B. Two-level bootstrap over the four cells
| Comparison | Mean diff. | 95% CI |
|---|---|---|
| minus | 5.3 | [-4.5, 14.1] |
| minus | 3.5 | [-1.0, 8.2] |
| minus | 12.7 | [0.7, 38.9] |
| minus | 18.2 | [1.2, 46.3] |
EC.2.7 Coverage of the Deployed Cost Bound
We check coverage empirically because the deployed grid and heads share warm data and use tuned confidence scales. Table 11 compares selected-arm bounds with provider-reported charges over two budgets and five seeds per dataset and (ten runs), excluding gate skips. Coverage is the fraction . All-call gap averages over all calls ( USD). Conditional severity averages over exceedances ( USD). Exceedance above the target core cutoff is the fraction of raw completion-token counts above .
At , coverage is 0.876 on GPQA and 0.988 on MATH500, above their respective targets . Coverage declines as increases. On GPQA, it falls below target at , reaching 0.751 and 0.715, while MATH500 remains above target at . For MATH500 at , coverage rounds from 0.9998 to 1.000, which explains why a positive gap is still reported. These pooled summaries do not establish simultaneous conditional coverage or identify why coverage declines.
Core overflow uses the target , which duplicate-edge correction can place below the actual tail interval. It does not use top edge .
Table 11: Executed-call cost-bound audit across .
| Dataset | cells | Coverage | All-call gap () | Cond. severity () | Target-core exceedance rate | |
|---|---|---|---|---|---|---|
| GPQA | 1 | 10 | 0.960 | 2.40 | 6.08 | 0.0126 |
| GPQA | 2 | 10 | 0.876 | 4.11 | 3.31 | 0.0137 |
| GPQA | 3 | 10 | 0.807 | 5.56 | 2.88 | 0.0124 |
| GPQA | 4 | 10 | 0.751 | 5.68 | 2.28 | 0.0116 |
| GPQA | 5 | 10 | 0.715 | 6.53 | 2.29 | 0.0112 |
| MATH500 | 1 | 10 | 1.000 | 0.03 | 12.28 | 0.0006 |
| MATH500 | 2 | 10 | 0.988 | 0.13 | 1.04 | 0.0015 |
| MATH500 | 3 | 10 | 0.970 | 0.76 | 2.54 | 0.0010 |
| MATH500 | 4 | 10 | 0.959 | 1.26 | 3.08 | 0.0009 |
| MATH500 | 5 | 10 | 0.944 | 1.49 | 2.68 | 0.0005 |
EC.3 Cost-Head Ablation on RouterBench
We compare three cost heads within one routing controller. K-Bit is the K-bit threshold-survival head implemented in ADP-HT. Continuous Mean replaces that head with a continuous output-length mean predictor. Mean-Adjusted adds a one-sided confidence correction to Continuous Mean.
Protocol. We use seeds 42–46 and budgets 5.00, 8.86, 10.00, 13.34, 20.00, 40.02, and 80.04 USD. Each seed applies the original20%/80% split. All heads share the warm observations, reward learner, dual update, pacing, model order, and test order.
Table 12. K-Bit, Continuous Mean, and Mean-Adjusted on ROUTERBENCH (five seeds).
| Budget (USD) | K-Bit | Continuous Mean | Mean-Adjusted |
|---|---|---|---|
| Panel A. Cumulative score, mean (sample standard deviation) | |||
| 5.00 | 15,989.4 (770.9) | 14,774.2 (768.9) | 15,502.3 (416.7) |
| 8.86 | 18,397.6 (462.3) | 16,923.7 (1,589.2) | 17,419.5 (1,048.8) |
| 10.00 | 18,673.3 (376.0) | 17,248.3 (1,359.2) | 17,446.2 (1,199.9) |
| 13.34 | 18,931.1 (515.2) | 17,851.0 (1,330.5) | 17,762.9 (1,310.1) |
| 20.00 | 18,996.2 (532.9) | 18,771.0 (883.9) | 18,668.4 (992.8) |
| 40.02 | 19,888.3 (315.2) | 20,072.6 (151.7) | 20,054.0 (188.7) |
| 80.04 | 20,272.6 (187.2) | 20,263.1 (195.8) | 20,283.6 (184.1) |
| Panel B. Mean number of queries served | |||
| 5.00 | 29,199.0 | 27,564.4 | 28,720.4 |
| 8.86 | 29,198.2 | 28,450.2 | 29,164.4 |
| 10.00 | 29,198.8 | 28,704.4 | 29,078.4 |
| 13.34 | 29,199.0 | 29,068.0 | 29,197.8 |
| 20.00 | 29,199.0 | 29,199.0 | 29,199.0 |
| 40.02 | 29,199.0 | 29,199.0 | 29,199.0 |
| 80.04 | 29,199.0 | 29,199.0 | 29,199.0 |
| Panel C. Mean score per served query | |||
| 5.00 | 0.5476 | 0.5361 | 0.5397 |
| 8.86 | 0.6301 | 0.5940 | 0.5972 |
| 10.00 | 0.6395 | 0.6004 | 0.5998 |
| 13.34 | 0.6483 | 0.6139 | 0.6084 |
| 20.00 | 0.6506 | 0.6429 | 0.6394 |
| 40.02 | 0.6811 | 0.6874 | 0.6868 |
| 80.04 | 0.6943 | 0.6940 | 0.6947 |
Table 12 shows that K-Bit leads at the tight and intermediate budgets, while Continuous Mean and Mean-Adjusted become more competitive as the budget expands. At the tightest budget, K-Bit reaches the end of the test stream, whereas the continuous heads exhaust their budgets earlier. It also achieves higher average quality per served query, so the gain reflects both broader service and the models selected. Once all three heads reach the full stream, allocation quality rather than service reach determines the comparison. K-Bit retains the strongest per-query performance through the intermediate budgets. Continuous Mean has the strongest per-query performance at the next-to-highest budget, and Mean-Adjusted holds a slight advantage at the highest budget.
EC.4 Validation and Analysis in a Numerical Example
We use a synthetic task stream to measure how closely ADP-HT approaches the optimal expected solved count. The design preserves model choice and retries under a common budget, with discrete outcomes that make a dynamic program (DP) tractable. We vary cost uncertainty, difficulty persistence, and budget while holding the remaining primitives fixed. All parameters are set before testing.
EC.4.1 Experimental Design
Each stream contains 1,000 tasks and allows at most calls per task. The three models, indexed by , are listed in order of increasing success probability and mean output cost. A task's observed type is easier () or more difficult (). Types are drawn independently with equal probability. Hidden difficulty is good () with prior probability and bad () otherwise, where and .
Let and denote model 's success probabilities conditional on good and bad difficulty. Given the hidden state and selected model, each call uses a fresh Bernoulli draw. The first-call success probability for type is . Table 13 gives these probabilities and two output-length distributions. Lengths are deterministic in the fixed setting. In the tail setting, parentheses give the probabilities of the listed lengths.
Table 13. Success probabilities and output lengths in the synthetic environment.
| Model | Fixed length | Tail length | ||||
|---|---|---|---|---|---|---|
| 0.80 | 0.20 | 0.650 | 0.350 | 2 | 2 | |
| 0.90 | 0.40 | 0.775 | 0.525 | 3 | 2 (0.8), 7 (0.2) | |
| 0.95 | 0.55 | 0.850 | 0.650 | 4 | 2 (0.8), 12 (0.2) |
Hidden difficulty is either redrawn independently from the type-specific prior at every attempt, labeled iid in the tables, or held fixed within a task, labeled persistent. Output length is independent of difficulty and success. Crossing these two difficulty settings with the two length distributions and initial budgets gives eight environments.
Before attempt , let be the total output length of the current task's failed calls. A new call with output length costs . Input and output have unit prices, and lengths and costs use synthetic units. Both policies make a first call whenever the balance is positive. After failure, they may call any model or abandon the task. Success, abandonment, or the fourth call ends the task. A call that reaches or crosses the budget is completed and credited before service stops, as in Section 3.3.
DP observes the same task type, call history, and budget ledger as ADP-HT, but also knows the outcome distributions. Neither policy observes hidden difficulty or future responses. We retain the ADP-HT learners, allocation rule, dual and pacing updates, and retry gate, with cost-label resolution , tail tolerance , and fixed controller defaults. Synthetic features replace embeddings. Let count failures of model on the current task, so . The unprojected feature is
where is the indicator function and 4, 36, and 40 are fixed normalization constants. The shared reward component projects these nine coordinates to four dimensions.
Each environment uses 20 test seeds shared across policies and three equally weighted warm initializations, each based on 32 tasks outside the operating budget. Warm logs are reused across budgets, giving 160 DP and 480 ADP-HT runs overall. Only selected responses are revealed. Confidence intervals (CIs) use 10,000 bootstrap resamples of the 20 test-seed blocks, retaining all three initializations within each block.
Observed type provides an imperfect difficulty signal, and persistent difficulty makes failures informative for later attempts. The input cost includes the initial prompt, retained failed outputs, and overhead from retries. The length settings vary uncertainty at a fixed mean output cost per call for each model, while the budgets vary resource scarcity. These settings reflect the general characteristics of LLM calls and routing.
EC.4.2 Dynamic Program
Before revealing the next task's type, let be the optimal expected additional solved count with tasks and balance remaining. Set if or . Once the current type is observed, the state is , where includes the current task, records its model-specific failure counts, and is its accumulated failed-output length. Let be the optimal expected additional solved count conditional on this state. The next attempt is . Under persistent difficulty, let denote the posterior probability of good difficulty, given the observed failures:
For independent difficulty, . Write for model 's next-call success probability at state . Let be the probability that model returns output length , and let be the unit vector that increments its failure count. Denote by the expected additional solved count from calling and acting optimally thereafter, and by the optimal continuation value if that call fails. Summing over the possible output lengths gives
Here is the realized call cost. Abandonment is available when and has action value . The value is the maximum action value over the available calls and, when permitted, abandonment. A new task starts with failure-count vector and accumulated output length zero. Averaging over its type gives
The recursion credits successful budget-crossing calls with zero continuation and permits final-task retries.
We define the Bellman loss as . It measures the chosen action's loss against the best action at that state, with optimal continuation. Here a can be either a model call or abandonment. Let be a nonanticipating routing policy, whose decisions use only information revealed before each decision, and let index all decisions it visits, including abandonment. Write and for the state and action at decision j, and SOLVED for the total number of tasks solved in the stream. For a fixed warm log, summing Bellman equations gives
The expectation averages task types and outcomes under policy . Sampled losses separate first calls and retries.
EC.4.3 Results and Interpretation
Let denote DP's optimal expected solved count for the full stream. Table 14 reports solved counts and action agreement. Agreement means a value within of the best
Table 14. Solved tasks and agreement with DP.
| Cost / difficulty | ADP-HT [95% CI] | ADP/ | Agreement | ||
|---|---|---|---|---|---|
| 2,000 | Fixed / iid | 336.30 | 309.80 [306.47, 313.73] | 92.12% | 31.32% |
| 2,000 | Fixed / persistent | 336.28 | 315.28 [312.97, 317.45] | 93.76% | 33.78% |
| 2,000 | Tail / iid | 336.32 | 312.52 [308.10, 317.42] | 92.92% | 34.07% |
| 2,000 | Tail / persistent | 336.31 | 315.48 [311.05, 319.92] | 93.81% | 33.70% |
| 5,000 | Fixed / iid | 763.27 | 741.98 [734.52, 749.47] | 97.21% | 51.93% |
| 5,000 | Fixed / persistent | 750.76 | 736.97 [731.97, 741.93] | 98.16% | 64.14% |
| 5,000 | Tail / iid | 767.50 | 735.55 [728.22, 742.65] | 95.84% | 51.12% |
| 5,000 | Tail / persistent | 754.77 | 729.80 [723.35, 736.05] | 96.69% | 59.66% |
ADP-HT gives simulated means and 95% test-seed-block intervals conditional on three fixed warm logs.
action at the same ADP-HT-visited state, including abandonment. Run-level fractions receive equal weight.
Ratios for individual warm logs range from 89.7% to 100.4%, comparing simulated means with an expectation. All eight paired DP-minus-ADP-HT mean gaps have positive 95% intervals.
Cumulative Bellman loss links decision differences to the expected reward gap in (40). We examine budget use to explain where this loss arises.
Table 15. Behavior in the fixed-length independent environment.
| Measure | ||||
|---|---|---|---|---|
| DP | ADP-HT | DP | ADP-HT | |
| Tasks served | 573.15 | 436.03 | 999.85 | 999.83 |
| First-call success among served tasks (%) | 59.23 | 71.51 | 67.53 | 71.41 |
| First-call successes | 339.50 | 309.80 | 675.20 | 714.02 |
| Retry calls | 0.00 | 0.00 | 122.40 | 41.87 |
| Retry successes | 0.00 | 0.00 | 95.60 | 27.97 |
| Solved tasks | 339.50 | 309.80 | 770.80 | 741.98 |
| Calls / solution | 1.69 | 1.41 | 1.46 | 1.41 |
| Cost / solution | 5.91 | 6.47 | 6.50 | 6.73 |
Means use each policy's own trajectories. Rates and ratios are calculated per run before averaging. Costs and calls include failures. DP counts are simulated. Table 14 uses the optimal expectation.

Figure 6. Mean Bellman loss per stream under ADP-HT by decision type.
ADP-HT attains 92.12% to 98.16% of DP's optimal expected reward despite action agreement of only 31.32% to 64.14%. Their different allocation patterns help interpret this result. First, under tight budgets, ADP-HT favors the stronger model , while DP mainly uses and . In the fixed-length independent setting, its higher first-call success rate comes with greater cost per solution and fewer tasks served (Table 15). Second, at the larger budget with fixed lengths, ADP-HT retries less often than DP under independent difficulty but more often under persistent difficulty, indicating that its recovery decisions vary with the failure process. Finally, first calls account for nearly all sampled Bellman loss under tight budgets and 54% to 67% at the larger budget, leaving a larger share of the loss to retry and abandonment decisions (Figure 6). These patterns also have practical relevance. Cascading accumulates the costs of successive calls [DBV25], and studies of conversations with progressively revealed instructions find that LLMs can retain earlier incorrect assumptions [LHZN26]. Where failed outputs remain in context and hinder correction, a stronger first call may avoid repeated errors and growing input costs. Several cheap retries may then cost more than a single expensive call. Thus, ADP-HT's tendency to invest in initial success may be useful in real LLM routing scenarios.
EC.5 Tail Costs and the Value of Future Service
We specialize Section 3 to identical tasks, known distributions, and one call per task. We compare the future service protected by a predictable call with the extra budget it consumes. Throughout this section, backlog means the number of unfinished tasks, including the current task; the initial backlog is T.
EC.5.1 Model and Optimal Call Sequence
The predictable model P has cost c and success probability u. The risky model R has success probability v and cost
Each call's success and cost are independent of the past, although they may be correlated within the call. A high-cost response always ends service and receives credit if successful under (2).
Let be the optimal expected number of solved tasks with tasks remaining and remaining budget . Set and for . For ,
The immediate risky reward is , including the high-cost response. For , let and be the optimal expected numbers of solved tasks when the first call uses and , respectively, with optimal choices thereafter. Their difference is
The last bracket is nonnegative because additional budget cannot reduce the optimum. A predictable call reduces the immediate success probability by and uses more budget than a low-cost risky call. Its benefit is the future service protected from termination.
Write , with . Thus is the expected number of solved tasks from at most risky calls, including the high-cost response. We call an initial sequence of predictable calls the predictable prefix and the following risky calls the risky suffix.
Proposition 2 (Predictable calls precede risky calls). Under (41), consider a predictable prefix of length m and define
Here is the maximum number of risky calls that can follow this prefix. Then
An optimal policy makes a maximizing number of predictable calls first and then uses on all remaining tasks until service stops to banlance the rewards and the risk.
Proof. Backward induction gives a deterministic optimal policy whose choices depend only on the current state. Every risky call that does not end service costs , so the model choices before any high-cost response form a deterministic sequence. Past successes give no information about future tasks. A predictable call on the final task or one that exhausts the budget can be replaced by : the immediate expected reward increases, and the expected reward from later tasks remains nonnegative.
Any adjacent pair in an optimal sequence therefore starts with remaining budget greater than . Swapping it to leaves the same state after a low-cost risky call. The expected rewards through the pair change from to , a strict gain of . Thus all predictable calls precede all risky calls. This predictable prefix must leave positive budget and at least one task. Its risky suffix admits at most calls, with call reached with probability . This proves (44) over all nonanticipating policies.
EC.5.2 Backlog and the Optimal First Model
Theorem 2 (A reversal as backlog increases). Suppose . Put , , and . An optimal policy either always chooses or chooses once and then uses . For , their values are
Then . Model is optimal first exactly when , where
Strict comparisons give a unique first model and equality gives a tie. At T = 1, R is uniquely optimal. A strict preference for R, then P, then R as T increases occurs exactly when
Proof. The budget restriction permits at most one predictable call that does not exhaust the budget, so Proposition 2 gives and . Their difference is . The adjacent-swap argument also implies that a globally optimal policy starting with uses no later predictable call. Hence this comparison identifies the optimal first model.
For , subtracting from gives . The number of risky calls following stops increasing at , giving the second expression. Both expected values stop increasing once . The expressions agree at their endpoints. Thus decreases to , then increases to if , and stays constant thereafter. Since , a strict middle preference for and a strict eventual preference for are equivalent to (48).
A short backlog leaves little future service to protect. An intermediate backlog makes avoiding termination valuable. With a long backlog, the low-cost risky calls displaced by predictable service can restore the preference for R.
For an exact example, take . Model has both a higher success probability and a lower mean cost, 2.6 compared with 4. Here , , and . The optimal first model is for , for , and for . At , a predictable first call followed by risky calls yields 3.702 expected successes, compared with 3.3616 under always choosing , a 10.1% increase. Figure 7 shows the exact values.
(a) Policy values

(b) Initial prices
Figure 7. Exact policy values in panel (a) and effective cost prices in panel (b). Shading marks backlogs where is optimal first. Each backlog is a separate initial state with the same budget and model distributions.
EC.5.3 General Budgets
When , at most one predictable call can leave positive budget for another call. For general , several predictable calls may be optimal. Proposition 2 still characterizes the predictable-first backlog region and when two reversals occur. Even with multiple predictable calls, that region remains an interval rather than alternating arbitrarily between and .
Theorem 3 (Backlog intervals for general budgets). Suppose , and retain . Define
Thus is the number of risky calls that fit after predictable calls, including the crossing response. For , model is an optimal first choice exactly when
The two cases give the same comparison at . Strict inequalities give a unique first model, and equality gives a tie. The predictable-first backlogs form an interval. A strict preference for , then , then as increases occurs exactly when
Proof. For , the value of predictable calls followed by risky calls is
The expected value of the risky suffix stops increasing at . Since
these thresholds are nonincreasing in , and .
If , then and . Every feasible positive prefix satisfies
Thus no positive prefix strictly improves on always choosing when . The one-call prefix strictly improves when and ties when . This gives the first case in (49).
If , every positive prefix is feasible and the expected value of its risky suffix has stopped increasing. The best value divided by among these prefixes is therefore , which gives the second case. The adjacent-swap argument in Proposition 2 converts these policy comparisons into first-model comparisons.
Before , the threshold strictly decreases. After , the best value among prefixes with is fixed, while the always-risky value weakly increases. Thus the predictable-first backlogs form an interval. At , the comparison is versus , so is strictly optimal first for some exactly when . A strict eventual return to occurs exactly when , giving (50). Model is uniquely optimal at because .
When , , recovering Theorem 2.
EC.5.4 Quantile Scores and Expected Completions
Let . For , the two quantiles are and . For , the risky quantile is , including equality under this convention. Write and . Throughout this subsection, each score keeps its success probabilities, cost estimates, and effective price fixed as varies.
Proposition 3 (Help and harm from a fixed quantile penalty). Suppose , , and . The fixed score always selects , whereas always selects . Writing and , their values are
The quantile score improves expected successes if and only if . Strict help at intermediate backlogs and harm at and all occur exactly when
Proof. The assumptions give strict score preferences. The call counts in (51) include the crossing response. Up to , strictly decreases because it averages . An improvement from the quantile score can therefore begin only once. From to , the predictable value is constant and the risky value increases. Both are constant afterwards. Any strict improvement must include . Combining its inequality with strict harm after gives (52).
Thus the model choices under both fixed scores are constant, but their ranking in expected solved tasks can change with the backlog. The changing value of future service drives this difference.
Even the mean and a single upper quantile together need not identify the optimal first model. Fix , , , , , and . In instance A, costs 0.5 with probability 0.8 and 10 otherwise. In instance B, it costs 2 with probability 0.95 and 10 otherwise. Both have mean 2.4 and 0.975-quantile 10.
Without a high risky cost, any two calls cost at most , so all three tasks are attempted unless a high risky cost occurs. Let be the optimal expected number of solved tasks with tasks remaining. The recursion becomes , with . Instance A has optimal sequence and value 2.70. Instance B optimally uses throughout and has value 2.8525. Thus the same mean and quantile summaries give opposite optimal first choices. At , fixed quantile pricing selects throughout and earns 2.55 in both instances. It improves on always choosing by 0.11 in A and loses 0.3025 in B. The difference is the probability of losing later service. For a fixed model-choice sequence, increasing further above changes neither when service stops nor the number of solved tasks. It still changes both fixed scores.
EC.5.5 Implications for the Effective Cost Price
In (15a), the effective price is . Consider initial decisions with the known success probabilities and cost quantiles. Hold these predictions, , , and fixed while varying only . Equation (12a) gives
when . This difference is nondecreasing in , so fixed initialization cannot reproduce both reversals in Theorem 2. For , wins at every nonnegative price.
When , there is also an explicit price that implements the optimal choices. At a state with and , define
Set for states with or . For any fixed , maximizing gives an optimal policy under .
If , the score difference is , as in Theorem 2. Otherwise the price is zero and is optimal since . Model also dominates when or . Backward induction establishes optimality. For fixed , the price first weakly increases and then weakly decreases with . It gives the optimal comparison between the two models and is a coefficient in the score, not necessarily the value of adding one unit of budget.
Equation (55) makes the adaptation explicit through the remaining budget and backlog in and the risky cost probability in . In ADP-HT, contains the remaining budget per unfinished task, and and respond to realized spending. The exact is a structural benchmark for how the price should vary with the value of future service. ADP-HT's empirical updates allow its effective price to respond to related state variables, which leading to better performance in routing.
Figure 7(b) uses and , giving because does not affect the plotted values. This initialized price crosses the cutoff once, whereas crosses it twice.