Short answer

Two Amazon engineers replaced Claude Sonnet 4.6 with a small decision model for labelling tickets and report about 98% lower cost per ticket, by their own list-price math. Much of the saving came from a shorter prompt and a one-token answer. In an iOS app, look for calls where the model picks from a fixed list. Shorten the prompt and ask for one token first. Then try the on-device model with a @Generable enum, or a Create ML text classifier, behind a remote switch with a fallback. Choose the confidence threshold from your own test set.

On November 9, two engineers who work on one of Amazon's big internal ticketing systems published a write-up on the Strands Agents blog. They had been using Claude Sonnet 4.6 to put a label on every incoming ticket. They swapped it for Strands Decider, a small "decision model", and by their own list-price math the cost per ticket fell by about 98%. The post climbed Hacker News the next day with more than 500 points, and several commenters asked why Sonnet was doing this job at all.

That question is the useful part for anyone shipping an iOS app with an AI feature. A lot of apps built quickly with Cursor, Claude Code, Rork or Bolt send every small decision to a large hosted model because that was the fastest thing to wire up. Sorting a support message, tagging a journal entry, picking which of five screens a user meant: these are closed choices. This post walks through what Amazon actually did, which parts carry over to a mobile app, and how to move those calls to something cheaper without breaking the feature.

What Amazon changed, in their numbers

The ticketing system receives customer escalations, capacity requests, automated alarms and security findings. Each ticket has to land in one of 20 categories. The team rewrote every label as a one or two sentence rule, added a "none" option, and asked the model to choose.

Strands Decider does not write text back. It takes a state and a set of options and returns a probability for each option plus a confidence score. The team ran an E4B build based on Gemma 4 on SageMaker, on ml.g5.xlarge instances with one A10G GPU each. The model uses about 19 GiB of the card's 24 GB.

Here is the comparison from their post:

MeasureClaude Sonnet 4.6Strands Decider E4B
Average time per call4,215 ms897 ms
Input tokens per ticket6,5542,009
Output tokens per ticket1701
Cost per ticket (list price)$0.0222about $0.0005
Cost per million ticketsabout $22,200about $500

The Sonnet figure uses $3 per million input tokens and $15 per million output tokens on Bedrock. The Decider figure is the hourly price of the instance, $1.408, spread over the tickets it handles. At about 640 ms per request one instance labels roughly 5,600 tickets an hour. Lambda costs are left out of both columns.

Two numbers in that table matter more than the headline. Output dropped from 170 tokens to 1, because the small model returns a choice instead of an explanation. Input dropped by about two thirds, because the small model has a 4,096 token window and the team had to cut the prompt down to fit. Part of the saving comes from the cheaper model. A large part comes from asking a shorter question and accepting a shorter answer.

Why it worked for them, and where they say it won't

The authors are clear about the conditions. The task is a closed choice from a known list. The volume is very high. Latency mattered. They also list the cases where they expect the approach to fail: when a label needs an explanation, when the list of labels changes often, or when the context a model needs will not fit in a few thousand tokens.

They did not flip a switch and hope. The stack has three modes controlled by AWS AppConfig. In BEDROCK mode Sonnet labels everything. In DUAL mode both models run, Sonnet's label is applied, and every disagreement is recorded and judged. In DECIDER mode only the small model runs. Rolling back takes a config change that they say finishes in about 45 seconds.

They also hit two problems worth knowing before you try this yourself. Their production label descriptions alone were longer than the small model's 4,096 token window, so on long tickets the oldest comments get dropped. And changing the order of keys in the JSON input moved the output probabilities by as much as 0.19. They now sort keys before every call and recommend checking for this before comparing runs.

The post does not publish accuracy, precision or recall. It says the E4B build beat production Sonnet on a separate test set and that live traffic in dual mode was used to judge every disagreement. Keep that in mind when you read the 98% figure: it is a cost figure measured by the people who made the change, and the quality claim is theirs too.

What this means for an iOS app

Your app is probably not labeling a million tickets a day. The lesson still applies, for three reasons.

First, the cost per call is the same shape at any scale. If your app sends a 2,000 token prompt to a frontier model every time a user saves a note, and the model writes back a paragraph you then parse for one word, you are paying for the paragraph. A free app with a few thousand daily users can run up a real bill this way, and the founder often finds out from the invoice.

Second, latency is felt by the user. A four second round trip to sort a support message is tolerable on a server. On a phone it is a spinner, and on a weak connection it is a failure state you have to design for.

Third, iOS already ships two ways to make closed choices without a per-request API bill. Apple's Foundation Models framework gives apps access to the on-device model behind Apple Intelligence, and Create ML plus the Natural Language framework let you train and run a small text classifier inside the app. Neither is a drop-in copy of Strands Decider, but both fit the same kind of task. If your app also uses Private Cloud Compute, Apple Now Sells $49.99 AI Usage Packs covers the usage limits to plan for.

Step 1: Find the closed-choice calls in your code

Start by listing every place the app talks to a hosted model. In an app generated with an AI tool these calls are often spread across view models, a networking helper and sometimes a backend function you forgot about. This script searches a repo for the usual signs and prints file and line numbers so you can review each one.

#!/usr/bin/env bash
# find-llm-calls.sh: list places that call a hosted LLM API.
# Usage: ./find-llm-calls.sh /path/to/repo
set -euo pipefail
ROOT="${1:-.}"

PATTERNS=(
  'api\.anthropic\.com'
  'api\.openai\.com'
  'generativelanguage\.googleapis\.com'
  'bedrock-runtime'
  '/v1/messages'
  '/v1/chat/completions'
  '/v1/responses'
  'max_tokens'
  '"model"[[:space:]]*:'
)

for p in "${PATTERNS[@]}"; do
  grep -RInE --include='*.swift' --include='*.ts' --include='*.js' \
       --include='*.py' --include='*.json' \
       --exclude-dir=node_modules --exclude-dir=.build \
       --exclude-dir=Pods --exclude-dir=DerivedData \
       "$p" "$ROOT" || true
done | sort -u

For each hit, write one line in a spreadsheet: what the call decides, how many options the answer can have, and what the code does with the reply. You are looking for calls where the code reads one value out of the response and throws the rest away. Typical examples in consumer apps:

  • Routing a support or feedback message to a category.
  • Deciding whether a user's text is a question, a complaint or a request.
  • Tagging a note, recipe or workout with one of a fixed set of labels.
  • Choosing which intent or screen a typed command maps to.
  • Yes/no checks such as "does this message contain an address".

Calls that summarize, rewrite, translate or chat are not candidates. Leave those alone for now.

Step 2: Collect a labeled test set before you change anything

Amazon's team tested on one set of tickets, tuned a confidence threshold, and then checked on a separate set. You need the same thing at a smaller size. A few hundred real examples with the label the current model gave, and a human correction where it was wrong, is enough to start.

Be careful where the examples come from. If they contain what users typed, you are handling personal data, and your privacy policy and App Store privacy details need to match what you store and where. Strip names, emails and phone numbers before the data leaves the device, or build the set from your own test accounts.

Split the set in two. Use the first part to tune prompts or train a model. Keep the second part untouched and use it only to compare the old path with the new one. Write the expected label next to each example so the comparison is a simple count.

Step 3, option A: Use the on-device model with a Generable enum

The Foundation Models framework lets you ask the system model to produce an instance of a Swift type. Apple's documentation says the @Generable macro works on structures and enumerations. An enum is exactly a closed choice, so the model can only answer with one of its cases.

import FoundationModels

@Generable
enum FeedbackCategory {
    case bug
    case billing
    case featureRequest
    case account
    case praise
    case none
}

func classify(_ text: String) async throws -> FeedbackCategory? {
    let model = SystemLanguageModel.default
    guard case .available = model.availability else {
        return nil   // fall back to your server path
    }
    let session = LanguageModelSession(
        model: model,
        instructions: "Pick the category that best fits the user's feedback."
    )
    let response = try await session.respond(
        to: text,
        generating: FeedbackCategory.self
    )
    return response.content
}

A few details from Apple's docs shape how you use this.

Availability is not guaranteed. The model only runs on devices and regions that support Apple Intelligence, and it can be unavailable while it downloads. Apple's sample switches over model.availability and handles .unavailable(.deviceNotEligible) and .unavailable(.modelNotReady) separately. In practice that means you keep your server path as the fallback and treat the on-device model as the fast lane for devices that have it.

The context window is small. Technote TN3193 says the on-device model has a context window of 4,096 tokens per session, the same size Amazon worked within. Instructions, the prompt, the schema generated from your @Generable type and the response all count against it. You can measure your inputs with tokenCount(for:) and profile a running app with the Foundation Models instrument in Instruments (Product > Profile, Blank template, then add the instrument). If you go over, TN3193 says the session throws exceededContextWindowSize, so truncate long input yourself before calling, the same way Amazon drops the oldest comments.

Keep each classification in a fresh session. The content tagging guide warns that reusing a session can make the model produce tags related to earlier turns. For a one-shot label, a new session per call avoids that and keeps the token count predictable.

Keep the type small. TN3193 recommends short property names and adding @Guide descriptions only where they improve results, because every description adds tokens. For an enum, clear case names usually do the job.

There is also a specialized model, SystemLanguageModel(useCase: .contentTagging). Apple describes it as producing tags for topics, emotions, actions and objects, in one to a few lowercase words. That is useful for open tagging such as "what is this note about". It does not pick from your fixed list, so for routing into known categories the enum approach above is the better fit.

One thing the on-device model does not give you is a probability per option. Amazon tuned a confidence threshold before applying a label. With a generated enum you get a single answer. Adding a none case, as Amazon did, gives the model a way to decline, and your test set tells you how often it picks the wrong case.

A third availability case to handle

The two cases above are not the full list. The availability check was compiled with Xcode 26.2 and run on a Mac with macOS 26.0.1, a machine that can run Apple Intelligence but has it switched off. It returned .unavailable(.appleIntelligenceNotEnabled). Some of your users will be in the same state: an eligible device with the feature turned off in Settings. That is their choice, so the app should take the server path without showing an error or asking them to change it.

import FoundationModels

enum LocalPath { case use, skipQuietly, retryLater }

func localPath() -> LocalPath {
    switch SystemLanguageModel.default.availability {
    case .available:
        return .use
    case .unavailable(.modelNotReady):
        return .retryLater      // still downloading, try again next launch
    case .unavailable(.appleIntelligenceNotEnabled),
         .unavailable(.deviceNotEligible):
        return .skipQuietly     // use the server path, show no error
    case .unavailable:
        return .skipQuietly     // any reason added in a later OS
    }
}

This compiled without warnings and returned skipQuietly on that Mac. Because the model was off, the @Generable example above was not run for this article, so the on-device path has no measured numbers here.

Step 3, option B: Train a small text classifier with Create ML

If you need a confidence score, or you need to support devices without Apple Intelligence, a trained classifier is closer to what Strands Decider does. Create ML's MLTextClassifier trains on a table of text and labels on your Mac and writes a Core ML model file. In the app, the Natural Language framework's NLModel loads it and returns labels with scores.

Training, in a macOS command line tool or a Swift playground:

import CreateML
import Foundation

// feedback.json: [{"text": "...", "label": "billing"}, ...]
let data = try MLDataTable(contentsOf: URL(fileURLWithPath: "feedback.json"))
let (train, test) = data.randomSplit(by: 0.8, seed: 42)

let classifier = try MLTextClassifier(
    trainingData: train,
    textColumn: "text",
    labelColumn: "label"
)

let metrics = classifier.evaluation(on: test, textColumn: "text", labelColumn: "label")
print("Classification error:", metrics.classificationError)

try classifier.write(to: URL(fileURLWithPath: "FeedbackClassifier.mlmodel"))

Using it in the app, with a threshold like Amazon's:

import NaturalLanguage
import CoreML

struct LocalClassifier {
    private let model: NLModel
    let threshold: Double

    init(threshold: Double = 0.7) throws {
        let ml = try FeedbackClassifier(configuration: MLModelConfiguration()).model
        self.model = try NLModel(mlModel: ml)
        self.threshold = threshold
    }

    /// Returns a label only when the model is confident enough.
    func label(for text: String) -> String? {
        let hypotheses = model.predictedLabelHypotheses(for: text, maximumCount: 1)
        guard let (label, score) = hypotheses.first, score >= threshold else {
            return nil   // send to the hosted model instead
        }
        return label
    }
}

The class name FeedbackClassifier is generated by Xcode from the model file name once you add the .mlmodel to the target. NLModel has been available since iOS 12, so this route works on far older devices than the on-device foundation model. The tradeoff is the one Amazon names: if your categories change every month, you retrain and ship a new model each time, while an enum prompt only needs a code change.

Pick the threshold from your held-back test set. Run every example, record the top score, and find the lowest threshold where the labels above it are right as often as the current hosted model. Everything below the threshold goes to the old path. That split alone can move most traffic off the expensive call while the hard cases still get the big model.

What 120 examples actually buy you

Step 2 says a few hundred examples are enough to start. To see what a smaller set gives, 120 feedback messages were written for this article, 24 for each of five labels (bug, billing, feature request, account, praise), and MLTextClassifier was trained on them with Xcode 26.2 on an Apple silicon Mac. Each message was scored by a model that had not seen it, in five rounds that each held back a fifth of the set. Three of Create ML's algorithms were tried with no tuning.

AlgorithmRight, no thresholdStays local at 0.7Right among thoseTime per callModel file
Maximum entropy (the default)72 of 120 (60.0%)6 of 120 (5%)5 of 60.06 ms8 KB
Transfer learning, static embedding69 of 120 (57.5%)84 of 120 (70%)49 of 84 (58.3%)0.24 ms1.1 MB
Transfer learning, BERT embedding80 of 120 (66.7%)100 of 120 (83%)68 of 100 (68.0%)14.4 ms1.4 MB

Three things stand out.

The training set is the limit. None of the three got past 67% with 96 training messages per round, and the mistakes were ordinary ones. The default model filed "How do I cancel my subscription?" under account and "Export to PDF produces an empty file" under feature request. Collect more labelled examples before you spend time on the algorithm.

A score means something different in each model. The default model rarely gave a score above 0.7, so the 0.7 threshold from the snippet above kept only 6 messages on the device. The embedding models gave high scores to wrong answers. The static embedding model filed "My card was declined but the money left my account" under account with a score of 0.95, and at a threshold of 0.9 it still kept 49 messages and got 19 of them wrong. A threshold copied from another project, this article included, tells you nothing. Pick it from your own held-back set, for the exact model you ship.

Speed is not the constraint. Even the slowest of the three answered in about 14 ms on the Mac, against the 897 ms Amazon reports for its small model and 4,215 ms for Sonnet. An iPhone will be slower than a Mac, but the gap to a network call is large.

The sweep itself is a few lines. Give it the expected label, the predicted label and the score for every held-back example:

// results: one entry per held-back example, from running the trained model on it.
struct Outcome { let expected: String; let predicted: String; let score: Double }

func sweep(_ results: [Outcome], thresholds: [Double] = [0.0, 0.5, 0.6, 0.7, 0.8, 0.9]) {
    for t in thresholds {
        let kept = results.filter { $0.score >= t }
        let right = kept.filter { $0.expected == $0.predicted }.count
        let share = 100 * kept.count / max(results.count, 1)
        let accuracy = kept.isEmpty ? 0 : 100 * right / kept.count
        print("threshold \(t): stays local \(share)%, right \(right) of \(kept.count) (\(accuracy)%)")
    }
}

For the default model on this set, the useful row was 0.6, where 17 messages stayed local and 16 were right. That is 14% of the traffic, which is not much. The numbers come from made-up messages and one small test, so they show the method and the size of the problem, not what your data will do. One note on the training snippet: the MLDataTable initializer it uses still compiles, with a deprecation warning that points to DataSource.

Step 3, option C: Keep it on the server, but ask a smaller question

Some apps cannot move work to the device: the classification happens in a backend job, or it needs data the phone does not have. You can still copy two things from Amazon's change without switching vendors.

Ask for one token back. Instead of "explain which category fits", ask the model to return only the category name, and set a low output limit. Amazon's output went from 170 tokens to 1, and at $15 per million output tokens on Sonnet 4.6 the output side was a meaningful share of the old cost.

Cut the prompt. Rewrite each label as one or two sentences, the way Amazon did, and send only the part of the user's text the decision needs. Then test a smaller model in the same family against your labeled set before assuming you need the large one. Several Hacker News commenters asked why Haiku was not tried first; the article does not say.

Step 4: Copy the three-mode switch

The safest part of Amazon's rollout is easy to copy in an iOS app. Put the choice of path behind a remote setting, run both paths for a while, and compare.

enum ClassifierMode: String, Codable {
    case remote   // hosted model only (today)
    case dual     // run both, apply remote, log disagreements
    case local    // local model first, remote below threshold
}

struct FeedbackRouter {
    let mode: ClassifierMode
    let local: LocalClassifier
    let remote: (String) async throws -> String
    let logDisagreement: (String, String?, String) -> Void

    func category(for text: String) async throws -> String {
        switch mode {
        case .remote:
            return try await remote(text)
        case .dual:
            let localLabel = local.label(for: text)
            let remoteLabel = try await remote(text)
            if localLabel != remoteLabel {
                logDisagreement(text, localLabel, remoteLabel)
            }
            return remoteLabel
        case .local:
            if let label = local.label(for: text) { return label }
            return try await remote(text)
        }
    }
}

Read mode from whatever remote config you already use, or from a small JSON file on your own server. Ship the build in remote mode, switch to dual for a week, review the disagreements, then move to local. If something goes wrong after launch, you flip the setting back without waiting for App Review.

Logging disagreements needs care on a phone. Don't upload the user's text by default. Log the two labels, a hash of the input and the score. If you need the text to judge a disagreement, ask the user, or do the dual run only on your own test devices.

Step 5: Check for the two problems Amazon found

Order sensitivity. Amazon saw probabilities move by up to 0.19 when only the JSON key order changed. If your input is built from a dictionary, the order can differ between runs. Sort keys before encoding (JSONEncoder has an outputFormatting option, .sortedKeys) and keep the order of your option list fixed, so that two runs on the same input are comparable.

Silent truncation. A small window means long inputs get cut. Decide on purpose what gets cut: the oldest messages in a thread, a quoted reply, a signature. Test a few of your longest real inputs and check that the label still comes out right after trimming.

The key order problem, reproduced

The key order risk is easy to see on your own machine. A five-key dictionary was encoded with JSONEncoder in a small Swift program, once with default settings and once with .sortedKeys, and the program was started three times:

run 1  plain : {"plan":"pro","locale":"en","title":"Refund","version":"3.2","body":"Charged twice"}
run 1  sorted: {"body":"Charged twice","locale":"en","plan":"pro","title":"Refund","version":"3.2"}
run 2  plain : {"version":"3.2","title":"Refund","plan":"pro","locale":"en","body":"Charged twice"}
run 2  sorted: {"body":"Charged twice","locale":"en","plan":"pro","title":"Refund","version":"3.2"}
run 3  plain : {"version":"3.2","plan":"pro","title":"Refund","body":"Charged twice","locale":"en"}
run 3  sorted: {"body":"Charged twice","locale":"en","plan":"pro","title":"Refund","version":"3.2"}

The default output came out in a different order on every launch, because Swift randomizes dictionary ordering for each process. The sorted output was identical each time. So two runs of your app can send the same data to a model in a different order without any code change, which is the situation Amazon measured. If you build a prompt by looping over a dictionary, the same applies: loop over the sorted keys.

Do the cost math for your own app

You don't need Amazon's scale to know whether this is worth a day of work. For a hosted model priced per token, cost per call is:

cost per call = (input tokens × input price + output tokens × output price) / 1,000,000

Multiply by calls per day and by 30. Then do the same for the new path. For the on-device model and a bundled Core ML classifier there is no per-request API charge; the cost is your engineering time and the share of calls that still fall back to the server. For a self-hosted model like Amazon's, the cost is the instance price per hour divided by the calls it handles in that hour, which is why their figure halves at full utilization. Revolut Says Self-Hosting Cut Its AI Coding Bill 90%. Run This Math Before You Copy It works through the self-hosted case in more detail.

If the monthly difference is small, keep the big model and spend the time elsewhere. If it is large, or if the latency is hurting the feature, the steps above are a reasonable afternoon's work to try.

A worked example

Here is the formula with numbers in it. Take an app that makes 5,000 classification calls a day. The long version sends a 2,000 token prompt and gets 170 tokens back, the output size Amazon started with. The short version sends 600 tokens and asks for one. The volume and token counts are examples, so put in your own. Prices are the Sonnet 4.6 list prices quoted earlier.

# Monthly cost of one classification call under four setups.
# Prices are the Sonnet 4.6 list prices quoted above: $3 input, $15 output per million tokens.
IN_PRICE, OUT_PRICE = 3.00, 15.00
CALLS = 5_000 * 30          # 5,000 calls a day

def per_call(tokens_in, tokens_out):
    return (tokens_in * IN_PRICE + tokens_out * OUT_PRICE) / 1_000_000

long_prompt = per_call(2_000, 170)    # long prompt, explanation back
short_prompt = per_call(600, 1)       # trimmed prompt, one token back

rows = [
    ("hosted, long prompt", long_prompt),
    ("hosted, short prompt", short_prompt),
    ("local for 14% of calls, rest long", 0.86 * long_prompt),
    ("local for 80% of calls, rest long", 0.20 * long_prompt),
    ("local for 80% of calls, rest short", 0.20 * short_prompt),
]
for name, cost in rows:
    print(f"{name:<36} ${cost:.6f} per call  ${cost * CALLS:>8,.2f} per month")

Run with Python 3.12, it prints:

hosted, long prompt                  $0.008550 per call  $1,282.50 per month
hosted, short prompt                 $0.001815 per call  $  272.25 per month
local for 14% of calls, rest long    $0.007353 per call  $1,102.95 per month
local for 80% of calls, rest long    $0.001710 per call  $  256.50 per month
local for 80% of calls, rest short   $0.000363 per call  $   54.45 per month

Read the rows in order. Shortening the question, with the same model and no new code on the device, takes the bill from $1,282.50 to $272.25 a month. A local classifier that handles only 14% of calls, which is what the 120-example model above managed, saves $179.55. The local path only beats the short prompt once it handles most of the traffic, and the 80% rows are an assumption about a better-trained model, not a result. So do option C first. It is the cheapest change, and it pays for the time you then spend collecting training data.

When to keep the big model

Amazon's own list is a good filter. Keep the large model when the user sees an explanation, when the label set changes weekly, or when the decision depends on long context such as an entire conversation history. Also keep it when the volume is low and the feature is still changing. Moving to a small model fixes the label set in place, and that is a cost early in a product's life.

The other case is quality you have not measured. The Strands post reports that the small model beat Sonnet on their held-out set, but it does not publish the accuracy numbers. Your own test set is the only evidence that matters for your app. If the local path is wrong more often than the hosted one on your data, the savings are not worth it.

FAQ

What is Strands Decider?

According to the Strands Agents blog post of November 9, 2026, it is a decision model: it takes a state and a set of options and returns a probability for each option plus a confidence score. Amazon's team ran an E4B build based on Gemma 4. The post links a public repository with serving notes but does not name a license or give a price for the model itself.

Did Amazon really save 98%?

That is the team's figure, computed from us-east-1 on-demand list prices: about $0.0222 per ticket on Sonnet 4.6 against about $0.0005 on a SageMaker ml.g5.xlarge. Lambda costs are excluded. The post says the change will save millions of dollars a year but gives no total.

Can I run Strands Decider on an iPhone?

The post describes a model using about 19 GiB of GPU memory on a server instance, so that build is not a phone model. On iOS, the on-device foundation model and Create ML text classifiers are the practical options for the same kind of closed choice.

Does the on-device model work on every iPhone?

No. Apple says availability depends on whether the device and region support Apple Intelligence, and the model can also be unavailable while it is downloading. Check availability and keep a fallback path.

How big can my prompt be on device?

Apple's TN3193 gives 4,096 tokens per language model session, counting instructions, prompts, schemas and responses. Use tokenCount(for:) to measure.

How many examples do I need to train a text classifier?

More than 24 per label. In a test for this article, Create ML's text classifier trained on 96 made-up messages across five labels got between 57.5% and 66.7% of held-back messages right, depending on the algorithm. Treat a few hundred real, corrected examples as the starting point and measure on a held-back set.

A kit for the cost side

If you want to put numbers on the hosted part before and after a change like this, Jerry's Opus 5.5 Coding Workflow & Cost Kit includes an editable .xlsx calculator for standard Claude API token charges, with manual rate inputs and visible formulas, plus workflow templates for planning and reviewing AI-assisted code changes. It estimates API charges from numbers you enter; it does not connect to your account or predict subscription limits.

Sources