Skip to content
atom®technologiesBook a call
Production AI

Promoting a fallback model to primary: the release gate to run first

A proposed release gate for changing the primary model or fallback order in a production AI agent: measure cost per successful task, check the candidate's rate-limit headroom, and capture cf-aig-step serving evidence before cutover.

A packed auditorium during a technology keynote
The short answer

Require three results before cutover: measured cost per successful task on a frozen production-like sample, the candidate's rate-limit tier against your peak request rate, and serving-step counts from the cf-aig-step header showing which model actually answered. Record a documented pass or fail with a named owner. This gate is our proposal, not a vendor guarantee.

The decision and the failure mode

Before you promote a fallback model to primary or reorder the fallback chain, require three results: a measured cost per successful task on a frozen, production-like sample; the candidate's rate-limit tier against your peak request rate; and serving-step counts showing which model actually answered each request. Cloudflare's published prices and limits supply the inputs, and the cf-aig-step response header supplies the serving evidence. We propose recording a documented pass or fail, with a named owner, before any cutover.

The failure mode is quiet. You promote a fallback because it rescued requests during incidents, the change looks cheap on the price list, but it costs more per completed task, or the new primary's per-model rate limit becomes your real ceiling at peak. Both failures are invisible in a dashboard that only counts successful responses. The checks below are designed to surface them before the change ships, not after.

Diagram: Promoting a fallback model to primary: the release gate to run first. 1. Cost per successful task, not list price to Rate-limit headroom is part of the gate; 2. Rate-limit headroom is part of the gate to Serving-step evidence: which model actually answered; 3. Serving-step evidence: which model actually answered to Write safety survives the model change.

Cost per successful task, not list price

Cloudflare's Workers AI pricing page prices the service at $0.011 per 1,000 Neurons, with a free allocation of 10,000 Neurons per day; using more than that requires the Workers Paid plan. The same page lists per-model token prices that differ in both directions: @cf/meta/llama-3.1-8b-instruct-fp8-fast is listed at $0.045 per million input tokens and $0.384 per million output tokens, while @cf/meta/llama-3.3-70b-instruct-fp8-fast is listed at $0.293 per million input tokens and $2.253 per million output tokens.

Here is the inference we draw, and it is an inference rather than a vendor's conclusion: a lower published price per token does not by itself prove a lower cost per successful task. Output length varies by model, retries consume tokens, and requests served by a fallback bill at the fallback's price. The only number that settles the question is a measured cost per successful task, computed from the same frozen sample for the current primary and the candidate. Our proposed method: freeze a production-like task sample before the run, log input tokens, output tokens and the serving step for every request, and divide total spend by successful completions for each model. Treat the result as a measurement, since your task mix drives it.

Rate-limit headroom is part of the gate

Cloudflare's Workers AI limits page states that Text Generation carries a default limit of 300 requests per minute unless the model requires the Workers Paid plan. For models that do require the paid plan, the limits are per account and per model: 20 requests per minute under standard Workers AI billing, and 50 requests per minute when prepaid AI Gateway credits are loaded and the gateway's Workers AI billing setting is set to Unified billing. The page also notes that beta models may have lower rate limits.

The inference: if a fallback model serves a material share of your requests, its per-model limit can become the effective ceiling for the whole agent even when the primary has headroom. So the gate has two rate checks. First, compare your peak requests per minute against the candidate's limit tier, including the share you expect to spill to fallback. Second, measure your current fallback share from serving-step counts, because that share determines whether the fallback's 20 or 50 requests-per-minute tier binds before the primary's default does. If the candidate sits in a lower tier than your peak, the promotion fails the gate regardless of token price.

Serving-step evidence: which model actually answered

Cloudflare's AI Gateway fallbacks documentation states that Cloudflare can trigger a fallback provider in response to request errors or predetermined request timeouts, and that the response header cf-aig-step indicates which step successfully processed the request: value 0 means the primary model served it, value 1 means the request fell back to the second model, and each further fallback increments the step number.

This header is the evidence that keeps the gate honest. Without it, a request that succeeded may have been answered by the fallback, and you would credit the wrong model with both the cost and the quality. During the trial run, log cf-aig-step on every response, then compute two numbers: the fallback share under the current primary, and the share of trial requests the candidate actually served when placed first. If the candidate cannot hold the primary position on your sample without frequent step-1 fallbacks, that is a fail, because the fallback's price and limit then dominate your real cost and ceiling.

Write safety survives the model change

The Amazon Builders' Library article on making retries safe with idempotent APIs describes a pattern in which a controlling process decomposes a workflow into calls to smaller services, and when a call fails, the simplest fix is to retry until it succeeds. The article states that this rests on a simplifying assumption that an operation can be retried without any side effects, and that the goal is to make sure the result of the call happens only once even if the call is made multiple times. Their concrete example of the undesirable outcome is a retry that ends up creating a second resource, such as a duplicate volume.

Our inference, and it is ours rather than the article's conclusion: promoting or reordering models changes error and retry patterns, so write safety is a separate requirement the gate must test on its own. If your agent's tool calls write data, we propose adding an idempotency check before cutover: replay a request with the same client request identifier and confirm the effect occurs once. That replay test is our proposed diligence step, not a method the AWS article documents; the article supplies the requirement, and you run the check against your own code.

Who owns the gate, and what changes the recommendation

We propose this split of ownership, and it is a proposal to adapt to your organization. The person who owns the agent's infrastructure runs the sample and produces the token, cost and serving-step logs. The engineering owner of the agent records the pass or fail against the three criteria and owns the rollback plan. Whoever owns the budget signs the cutover. One person can hold two of these roles, but the pass-or-fail record should name who decided and on what evidence.

Conditions that change the recommendation: a candidate in a lower rate-limit tier than your peak requests per minute, a material fallback share that makes the fallback's limit the binding constraint, non-idempotent write paths surfaced by the replay test, or a vendor price or limit change. Cloudflare's pages are live documentation, so re-check prices and limits close to the cutover date. Finally, passing this gate settles one decision, not the whole system: NIST describes its AI Risk Management Framework as guidance intended for voluntary use, aimed at cultivating trust in AI technologies, and the NIST page we reviewed is an overview of the framework, so broader risk management is a separate effort.

The checklist

  1. Record the candidate model's published input and output token prices from the vendor pricing page, with the date you checked them.
  2. Confirm whether the candidate requires the Workers Paid plan, and which limit applies: the Text Generation default of 300 requests per minute, 20 per minute under standard billing, or 50 per minute with prepaid credits and Unified billing.
  3. Check whether the candidate is a beta model, since the limits page says beta models may have lower rate limits.
  4. Freeze a production-like task sample before the trial and record its size and task mix.
  5. Log input tokens, output tokens and the cf-aig-step value for every request in the trial.
  6. Compute cost per successful task for the current primary and the candidate from the same sample.
  7. Compute the fallback share under the current primary from the cf-aig-step counts.
  8. Compare your peak requests per minute, including expected fallback share, against the candidate's limit tier.
  9. Run the replay test this article proposes for write-side tool calls: send the same request twice with the same client request identifier and confirm the effect occurs once. The idempotency requirement comes from the AWS Builders' Library; the replay itself is our proposed check, not a documented vendor method.
  10. Record a pass or fail against all three criteria, with a named owner and date, before any cutover.
  11. Write down the rollback: the primary and fallback order you revert to if cost per successful task or fallback share regresses after cutover.
  12. Re-check the vendor's published prices and limits immediately before cutover, since live documentation can change.

Questions

How large should the task sample be?

We propose freezing a sample large enough to cover your real task mix and peak concurrency before the run, and recording its size so the result is reproducible. The right number depends on your traffic; pick one you can defend and write it down.

Does a cheaper token price guarantee savings?

No. Cost per successful task is a measured result that depends on output length, retries and fallback steps. The published prices from Cloudflare's pricing page are inputs to the calculation, not the answer.

Can we raise the rate limit instead of changing models?

Possibly. Cloudflare's limits page states that loading prepaid AI Gateway credits and setting the gateway's Workers AI billing setting to Unified billing raises the paid-model limit from 20 to 50 requests per minute, and the pricing page states that requests to frontier models using prepaid credits receive higher rate limits. Whether either path covers your peak is a check you must run against your own traffic.

How long should the gate take?

Our proposal, not a measured figure: the sample run, the log analysis and the pass-or-fail review should fit inside one sprint if the logging is already in place. Building the logging from scratch is the long pole.

Does passing this gate make the agent production-safe or compliant overall?

No. It settles one decision: this promotion, on this sample, at these prices and limits. NIST describes its AI Risk Management Framework as guidance intended for voluntary use, and the page we reviewed is an overview of the framework, so broader risk management is its own effort.