Reverse-Engineering AI Coding Tool Quotas: A Guide to Optimizing Subscription Costs

    AI coding assistants have moved almost entirely to subscription plans, but the pricing tiers they advertise often hide an opaque billing model. This article shows how a leaked high-precision float in a platform's usage readout can be turned into a reliable signal about the real quota structure. Using continued fractions and the Stern-Brocot tree, you can recover the hidden rational ratios behind credit consumption, compare advertised multipliers against actual ones across different time windows, and turn subscription choice into a solvable optimization problem. It closes with a decision model and four practical principles for spending less on subscriptions.

    1. The Problem: Opaque Billing Under Subscriptions

    With AI coding assistants now almost universally sold as subscriptions, one question keeps coming up: which tier should I actually buy? Vendors typically advertise that a higher tier offers “several times the usage,” but they rarely disclose how usage is measured internally. The price table looks clear at first glance, yet it conceals a layer of abstract billing.

    That layer usually tracks consumption in an internal unit such as “compute credits.” Its key characteristics are:

    • Models of different capability tiers are consumed at different rates; the more capable the model, the higher the per-call cost;
    • Output-side consumption is typically much higher than input-side consumption;
    • The advertised multipliers (for example, “5x usage”) do not necessarily match the real internal quota.

    As a result, “the cheapest subscription” is never about the sticker price. It is about which tier’s quota range your actual usage curve fits into with the least waste. Answering that requires first making the hidden quota structure visible. Interestingly, this kind of information is sometimes leaked by accident through a single technical detail.

    2. The Precision Leak: An Unrounded Float

    Some platforms, when echoing usage data on their web front end, occasionally return high-precision floats that have not been formatted at all, for example:

    1. 0.16327272727272726

    A 17-digit decimal with an obvious repeating segment (the 27 recurs). Such a number is almost certainly not set by hand; it looks more like an internal ratio that was exposed directly after being used in a calculation, without any rounding. The presence of a repeating decimal usually hints at an underlying “rational ratio” behind it—for example, a conversion factor of the form A/B.

    This opens a gap for reverse-engineering: as long as you can recover the most likely original fraction from an approximate float, you can infer the true multiplier relationships between models, between input and output, and between the quotas of different tiers.

    3. The Math Tools: Continued Fractions and the Stern-Brocot Tree

    Approximating the simplest fraction from a real number is a classic problem in number theory. The two methods widely accepted in practice are continued-fraction expansion and Stern-Brocot tree search, and the two are essentially equivalent.

    The Stern-Brocot tree takes 0/1 and 1/0 as its left and right boundaries. At each step it takes the “mediant” of the two adjacent fractions (add numerators, add denominators) as the approximation point, then converges by checking whether the target value falls to the left or the right. Its advantage is that, given an upper bound on the denominator, it can efficiently find the simplest fraction closest to a float value.

    Here is an illustrative implementation:

    1. def stern_brocot_recover(target: float,
    2. max_denominator: int = 10**6,
    3. tol: float = 1e-15):
    4. """
    5. Iteratively approximate target on the Stern-Brocot tree.
    6. Return the simplest fraction closest to target under the
    7. denominator limit.
    8. """
    9. left_n, left_d = 0, 1 # left boundary 0/1
    10. right_n, right_d = 1, 0 # right boundary 1/0, representing +∞
    11. while True:
    12. mid_n = left_n + right_n
    13. mid_d = left_d + right_d
    14. if mid_d > max_denominator:
    15. break
    16. approx = mid_n / mid_d
    17. if abs(approx - target) < tol:
    18. return mid_n, mid_d
    19. if approx < target:
    20. left_n, left_d = mid_n, mid_d
    21. else:
    22. right_n, right_d = mid_n, mid_d
    23. return left_n, left_d

    In engineering practice, the standard library’s continued-fraction approximation is often more concise:

    1. from fractions import Fraction
    2. def recover_fraction(x: float, max_denominator: int = 10_000) -> Fraction:
    3. # limit_denominator internally uses continued fractions to find
    4. # the best approximation on the Stern-Brocot tree
    5. return Fraction(x).limit_denominator(max_denominator)
    6. samples = [0.16327272727272726, 1.6666666666666667, 0.6, 0.2]
    7. for s in samples:
    8. print(s, "->", recover_fraction(s))

    The output restores these “suspicious decimals” to clean fractions, for example 0.6 -> 3/5, 1.666... -> 5/3, and 0.2 -> 1/5. These ratios happen to match common billing characteristics such as “more capable models are consumed faster” and “output is more expensive than input.”

    4. Recovering Usage Ratios and the Quota Structure

    With this toolkit plus several usage samples, you can reconstruct the quota system piece by piece, like solving a puzzle. The typical steps are:

    1. Capture a baseline: Record the lowest tier’s 5-hour rolling allowance and its weekly cap as the baseline B.
    2. Capture higher-tier samples: Record the usage figures the higher tiers report over the same time window.
    3. Compute the ratios: Divide the higher-tier figures by the baseline to get floating-point multipliers.
    4. Rational reconstruction: Run continued-fraction recovery on the multipliers to compare the “advertised multiplier” against the “true multiplier.”

    A common result is that a “5x” multiplier advertised by the vendor is actually close to 6x in the 5-hour window but close to 8x at the weekly cap—the true multiplier differs across time dimensions. This means that for some tiers, the value in “short-term, high-frequency use” scenarios can be far better than the sticker price suggests.

    5. From Reverse-Engineering to Plan Selection: Quantifying Your Real Usage

    Once the quotas are clear, choosing a plan becomes a computable optimization problem. There are three core variables:

    • Peak concurrency: Your densest consumption within the 5-hour window, which determines how large a “short-term allowance” you need;
    • Periodic total: Your accumulated consumption over a week, which determines whether the weekly cap is enough;
    • Capability mix: The ratio of high-capability to lightweight models in your daily calls, which directly affects credit consumption.

    A simple decision model can be written as:

    1. def pick_plan(peak_5h, weekly_total, plans):
    2. """
    3. plans: [{"name":..., "cap_5h":..., "cap_week":..., "price":...}, ...]
    4. Return the cheapest tier that satisfies the quota constraints.
    5. """
    6. feasible = [
    7. p for p in plans
    8. if peak_5h <= p["cap_5h"] and weekly_total <= p["cap_week"]
    9. ]
    10. return min(feasible, key=lambda p: p["price"]) if feasible else None

    Plug your measured peak_5h and weekly_total into it, and you can avoid the waste of “buying a high tier but only using half of it,” as well as spot the hidden time cost of “repeatedly hitting the cap on a low tier and being forced to wait for a reset.”

    6. Four Practical Principles for Cost Optimization

    Putting it all together, rational subscribing boils down to four principles:

    1. Choose by peak, not average: Sudden bursts of intensive use are more likely to trigger short-term caps, so the short-term allowance is the real bottleneck.
    2. Call by capability tier: Offloading tasks that clearly do not need a high-capability model to a lightweight one can significantly dilute credit consumption.
    3. Watch the input/output structure: Because output is more expensive, the biggest gains come from scenarios where structured prompts can reduce redundant output.
    4. Re-evaluate dynamically: Usage changes as projects move through different phases, so it is better to periodically re-sample and recompute your plan rather than committing to one long subscription.

    For teams that need centralized management and elastic scaling, general-purpose capabilities such as monitoring and alerting, logging services, and usage dashboards can aggregate call volume, credit consumption, and cost for continuous observation, turning plan selection from “a gut feeling” into “a data-driven decision.”

    7. Conclusion

    A single unrounded float traced out a complete quota-recovery chain: from the clue of the precision leak, to the rational inversion via continued fractions and the Stern-Brocot tree, to quantified selection and cost optimization. For developers, this is both an interesting math exercise and a reusable methodology—when facing an opaque billing system, model first, measure second, and decide last. Only then can you truly make sure that every dollar of your subscription goes where it counts.