Braj Kishore
JourneyVaultML FoundationsAI PM GuideAgenticNewsWork With MeMentorshipPulseNow
Say hi

Hiring · Building · Investing

Have a system — or a team —that needs to scale?

info@avyxon.ai

Usually replies within a day · track record here

JourneyVaultML FoundationsAI PM GuideAgenticNewsWork With MeMentorshipPulseNow
LinkedInXYouTubeSubstackInstagramThreadsFacebookDiscordGitHubTopmate
© 2026 Braj Kishore · Bengaluru, INThink Big · Start Small · Scale Fast
Agentic engineering
Lesson 27Leading

Unit economics

Most engineers cannot do this arithmetic. That is exactly what makes it the most differentiating thing in this curriculum for a CTO or Head of Engineering conversation. It is also not hard: one formula, and one honest denominator.

Sell one more seat of ordinary software and serving it costs you almost nothing. Sell one more seat of an agentic product and it costs you tokens. Every resolved task consumes them. Every retry consumes them again. Every failed attempt consumes them and produces nothing.

That is the whole difference. A software business has a cost of goods sold that barely moves with usage; an agentic product does not. So gross margin here is not a consequence of the pricing page. It is a function of engineering decisions: trajectory length, cache design, success rate.

The shape of this problem is not new. Casado and Bornstein described it for the previous generation of machine-learning companies in 2020. They reported gross margins “often in the 50-60% range — well below the 60-80%+ benchmark for comparable SaaS businesses”, with as much as a quarter of revenue going to cloud.

Do not quote those particular figures as current. They come off a different cost curve. The mechanism has aged far better than the numbers: every input has to be processed, one way or another, and processing costs money per unit.

How we built our multi-agent research systemAnthropicThe New Business of AI (and How It’s Different From Traditional Software)a16z
Interactive · the cost stack, one screen

Five parts of one run, and how differently each one responds

The bottom row is the reason this is worth looking at side by side: the same effort spent on different columns buys wildly different savings. Select a part for the caveats.

Where the money goes
System prompt and tool schemas. Identical on every turn, and re-sent on every turn, because the agent has no memory between them.
Everything the earlier turns wrote — tool output and model replies — re-sent in full on every later turn. This is the part that surprises people on the first invoice.
What the model writes back on each turn, billed at the output price. The one part of the bill that caching never touches, because caching applies to input.
Nothing. Failed runs consume tokens and produce no outcome, and the outcome carries the cost of every attempt it took to reach it.
The per-unit price on the input and output tokens above. Set by your provider and by which model you send the call to.
The lever that moves it
Prompt caching. A cache read is billed at 0.1× the base input price, so the stable part drops to a tenth after the first turn.
Delete turns. Removing one unnecessary tool call from a long trajectory saves far more than it appears to.
Fewer turns, and shorter replies per turn. The same lever as the transcript, pulled for a different reason.
The success rate itself — and, before that, a definition of resolved that is owned by someone who is not measuring their own success.
Model mix — a cheap model first, escalating to an expensive one only on a measured signal: difficulty, low confidence, or a failed check.
How it responds when you pull the lever
Linear in turns
One prefix per turn — grows with N, not with N².
Quadratic in turns
Doubling the turns roughly quadruples this term.
Linear in turns
One reply per turn — no re-sending, so no square.
Divides everything
At 70% success, every outcome costs ~43% more than cost per attempt.
Straight multiplier
Scales the whole bill one-for-one, and nothing else.

One column is quadratic, two are linear, one is a divisor and one is a multiplier. That is the entire reason a cost conversation about model price usually goes nowhere.

Why cost grows with the square of the trajectory

Start with the mechanism, because the arithmetic falls straight out of it. An agent has no memory between turns. The whole state of a run is an array of messages that you rebuild and resend on every iteration — lesson 04 works through why. So the model re-reads the entire transcript on every turn, and you are billed for the whole transcript every turn.

Watch what that does to one concrete run. Say the fixed prefix — system prompt and tool schemas — is 2,000 tokens, and each turn adds another 1,000 tokens of tool output and model reply.

Turn 1 sends 2,000 tokens. Turn 2 sends 3,000: the same prefix, plus what turn 1 added. Turn 3 sends 4,000. By turn 10 you are sending 11,000 tokens to buy one more step.

Now add the turns up. A ten-turn run bills 65,000 input tokens. A twenty-turn run bills 230,000 — three and a half times the input bill for twice the work. The extra turns are not the expensive part. Re-sending everything the earlier turns wrote is.

The formula just says that in general. On turn t you send the fixed prefix plus everything the previous t−1 turns added. Summed across a run of N turns, the billed input is:

∑t=1N(prefix+(t−1)⋅added)=N⋅prefix  +  added⋅N(N−1)2\sum_{t=1}^{N}\bigl(\text{prefix} + (t-1)\cdot\text{added}\bigr) = N\cdot\text{prefix} \;+\; \text{added}\cdot\frac{N(N-1)}{2}t=1∑N​(prefix+(t−1)⋅added)=N⋅prefix+added⋅2N(N−1)​

The first term is linear in the number of turns. The second is quadratic — it grows with the square of the trajectory. That is why a twenty-turn agent does not cost twice a ten-turn agent: on the growth term it costs roughly four times as much. It is also why deleting a single unnecessary tool call from a long trajectory saves far more than it appears to.

cost.py
CACHE_READ = 0.10   # cache reads are billed at 0.1x the base input price
CACHE_WRITE = 1.25  # a 5-minute cache write is billed at 1.25x


def billed_input_tokens(turns, prefix, added_per_turn):
    """Input tokens billed across one whole trajectory.

    Turn t resends prefix + (t - 1) * added_per_turn, so summing over
    t = 1..turns gives a term that is linear in the prefix and a term
    that is QUADRATIC in the number of turns. The second one is the
    one that surprises people.
    """
    return turns * prefix + added_per_turn * turns * (turns - 1) // 2


def cost_per_successful_outcome(
    turns, prefix, added_per_turn, output_per_turn,
    usd_per_m_input, usd_per_m_output,
    cache_hit_rate,   # 0.0 - 1.0, share of input tokens served from cache
    success_rate,     # 0.0 - 1.0, share of attempts that resolve the task
):
    multiplier = cache_hit_rate * CACHE_READ + (1 - cache_hit_rate) * CACHE_WRITE
    billed_in = billed_input_tokens(turns, prefix, added_per_turn) * multiplier
    billed_out = turns * output_per_turn

    per_attempt = (
        billed_in * usd_per_m_input / 1e6
        + billed_out * usd_per_m_output / 1e6
    )

    # Failed attempts still cost tokens. The outcome carries the cost of
    # every attempt it took to reach it, which is the number your pricing
    # has to clear.
    return per_attempt / success_rate
The whole model. The subtlety is all in the last line. Dividing by the success rate is what turns cost per call into cost per outcome, and it is the division almost nobody does.

Run your own numbers

Put in a current token price. Do not trust one written into a lesson: model prices move, and any figure hardcoded here would be wrong within a quarter. The defaults are round numbers, chosen to be obviously illustrative.

Interactive · cost per successful outcome

What a trajectory actually costs, and what it costs when it fails

Prices are round illustrative defaults, not quotes — put your own current per-million-token numbers in. Everything else is arithmetic you can check by hand.

The trajectory
8
4.0k tok
1.2k tok
300 tok
Prices and outcomes
$3.00
$15.00
72%
$2.00
70%

Reads are billed at 0.1× the base input price and five-minute writes at 1.25×, so the effective input multiplier here is 0.445×. At a 0% hit rate caching costs you more than not caching, which is the case people forget.

Billed input tokens per turn
turn 1 · 4.0kturn 8 · 12.4k

You are billed for the whole area, not the last bar. 65.6k input tokens across the run: 32.0k of prefix resent 8 times, plus 33.6k from the transcript growing — the term that scales with the square of the turn count.

Cost per attempt
$0.124
Per successful outcome
$0.172
Healthy gross margin
91%

At $2.00 charged against $0.172 of inference per resolved task. Of that, $0.048 is spent on attempts that did not resolve anything — a cost line that a cost-per-call metric never shows you.

The square law, both directions

Removing one turn cuts the bill by 17.0%. Doubling the turn count multiplies it by 2.8× — not by two. That gap is the entire argument for spending engineering time on shortening trajectories rather than on negotiating the token price.

Plans & pricingClaude
Move the turn slider and watch the two right-hand numbers pull apart. The gap between cost per attempt and cost per successful outcome is money you spent on runs that resolved nothing. At a 70% success rate, every outcome costs you roughly 43% more than your per-call metric reports. And a per-call metric will never show you that gap, because it does not know which runs worked.

Caching is the margin lever, and it has an edge case

Three multipliers are worth memorising, because they are the arithmetic behind every caching argument you will ever make. A five-minute cache write is billed at 1.25 times the base input price. A one-hour write is billed at 2 times. A cache read is billed at 0.1 times.

That last number is the lever. The stable part of your prompt — system instructions, tool schemas, a policy document — drops to a tenth of its price on every turn after the first. Given what the square law does to a long run, that is a large lever.

Two edges to know before you promise anyone a margin improvement. The first is a floor. There is a minimum cacheable prefix, in the range of hundreds to a few thousand tokens depending on the model. Below it, caching does nothing at all. It does not error either. It just quietly fails to help.

The second edge is worse. At a low hit rate, caching costs more than not caching: you pay the 1.25× write premium and never collect enough 0.1× reads to earn it back. Set the hit rate to zero in the calculator, toggle the cache off, and watch the cost drop. That is the case people forget when they enable caching everywhere by default.

So prompt layout is now a cost decision. Stable content first, volatile content last, so the cache boundary falls in a useful place. Chip Huyen’s assessment is the right one: cache is the most underrated component of an AI platform.

One caveat on that. Prompt cache, exact cache and semantic cache are three different levers with three different correctness risks, and only the first is free of them.

Seat-based pricing over usage-based COGS

The structural problem fits in one sentence, and that sentence is the one to say to a board: a seat is a fixed price for an unbounded quantity of a variable cost.

Two customers on the same plan pay you the same amount. They can differ by an order of magnitude in what they cost you to serve. Nothing in the pricing model notices.

Agents make this worse, because the variance comes from the shape of requests rather than the number of them. Anthropic report that agents use roughly four times the tokens of a chat interaction, and multi-agent systems about fifteen times.

So a customer whose workflows happen to trigger the long trajectory is not using your product more often. They are using a fifteen-times-more-expensive version of it, at the same price.

There is no clean answer here, and anyone who offers you one is selling something. Three shapes are actually in use: a seat with a fair-use ceiling and metered overage; a hybrid platform fee plus consumption; and outcome-based pricing, where you charge per resolved task.

My own view, offered as opinion. Outcome pricing is the only one that aligns the incentive correctly, because you are paid when the agent works. It is also the only one that needs the instrumentation in this lesson to exist before you can quote a price. That ordering is usually what stops people, not the pricing theory.

Building A Generative AI PlatformChip HuyenBuilding Effective AI AgentsAnthropic

Cost per call, cost per outcome, and the metric that games itself

Cost per call is the easy metric. It is also the wrong one, because its denominator is calls, and nobody is buying calls from you. They are buying resolved problems.

Cost per resolved outcome needs three things. A definition of resolved. A way to measure it after the customer has left. And an owner who is not being assessed on the number. Miss any one of the three and the metric silently reverts to a volume counter.

Contact centres have a name for the metric that goes wrong this way: containment, the share of conversations handled without a human. It is easy to instrument and it looks like an outcome.

It is also trivially gamed. An agent that simply refuses to escalate achieves perfect containment, whatever result it actually produced. Containment measures where the conversation ended, not whether the customer’s problem did.

A metric that resists this has to be attached to the transaction and measured after it. Two published answers are worth copying. Nubank use transactional NPS on the specific interaction, backed by an auditor model scoring every conversation.

Farmer.Chat publish a denominator instead: roughly 75% of user questions answered, with the unanswered quarter broken down as 66% content gaps, 23% out of context and 11% out of collection. That breakdown is the useful artefact. It tells you which failures are an engineering problem and which are a content one, and those go to different teams.

What happens when the metric that mattered was never instrumented

🇸🇪 Sweden

Klarna — a containment number in February, a reversal fifteen months later

2.3M
chats in month one
~700
full-time agents, claimed equivalent
15 months
to the public reversal

Klarna’s own release of 27 February 2024 reported that its AI assistant had handled 2.3 million conversations in its first month, two-thirds of all customer service chats, doing “the equivalent work of 700 full-time agents”, with resolution time down from 11 minutes to under 2 and a projected $40m profit improvement for the year. Those figures are company-reported. Now read the list again as metrics rather than as achievements: a volume, a share, a headcount equivalence and two durations. The release did contain one genuine outcome proxy — a 25% drop in repeat inquiries — and it is not the figure that travelled.

Fifteen months later, on 8 May 2025, the CEO told Bloomberg that “cost unfortunately seems to have been a too predominant evaluation factor when organizing this, what you end up having is lower quality”. The company began recruiting human agents again. The engineering lesson is not that the agent was bad. It is that two-thirds of chats handled is a containment metric, and an agent that declines to escalate scores perfectly on it. Whatever quality measure would have caught this fifteen months earlier was not in the release, and on the available evidence was not being watched. So instrument the denominator before you publish the numerator. Once a containment figure is in a press release, it becomes the number the organisation optimises.

Budget three lines, where most teams budget one. Inference tokens are the obvious line. The second is evaluation and human labelling — a recurring cost rather than a setup cost, because the eval set has to track production traffic. The third is incident response for non-deterministic failures. That is the line finance will not have heard of, and it is the one that makes the case for the controls in lesson 28.

What to actually do about this, at your size

Two of these are skips at seed, and both of them look like responsible engineering. That is exactly what makes them expensive. They are a way of doing infrastructure work instead of finding out whether anyone wants the product.

Interactive · calibrate to your stage

What to actually do about this, at your size

Nearly all guidance on this topic is written for one company size and then read by everyone. Pick yours — the list re-sorts, and what you should deliberately not build drops to the bottom.

  • Per-run cost attributionNon-negotiable

    Input, output, cache-read and cache-write token counts written to the trace on every run, with the outcome beside them.

    At this stage · Now joined to the outcome, so you can compute cost per successful outcome rather than cost per call. This is the single field that separates a defensible answer from a guess in a CTO conversation.

  • Prompt cachingDo it

    A stable prefix — system prompt, tool schemas, retrieved documents — marked so repeated turns read it rather than reprocess it.

    At this stage · Now worth designing the prompt around: stable content first, volatile content last, so the cache boundary falls in a useful place. This is usually the largest single margin lever available and it needs no new infrastructure.

  • Cost per successful outcomeDo it

    A single tracked number: total inference spend divided by tasks actually resolved, not by calls made.

    At this stage · On the dashboard beside latency and error rate. The definition of 'resolved' is the hard part and it must be owned by someone who is not measuring their own success.

  • Per-tenant budget enforcementCheap version

    A hard spend ceiling per customer, enforced in code, that fails the run rather than the invoice.

    At this stage · A soft ceiling with an alert. You now have one customer whose usage looks nothing like the others, and the useful output is finding out who they are rather than stopping them.

  • Model-mix routingCheap version

    Cheap model first, escalating to an expensive one only on a measured signal — difficulty, low confidence, or a failed check.

    At this stage · One split, on one clearly separable class of easy requests, defended by the eval set. Two models is a routing decision; five is a research project.

Nothing is optional at this stage. That is itself the finding — the cost of the control set is part of the cost of operating here.

Gartner Predicts Over 40% of Agentic AI Projects Will Be Canceled by End of 2027Gartner, 25 June 2025

What to remember

  1. 1
    Cost is quadratic in trajectory length

    Every turn resends the whole transcript, so billed input across a run is N·prefix + added·N(N−1)/2. Doubling the turns does not double the bill. Removing one tool call from a long run saves far more than it looks like it should.

  2. 2
    Divide by the success rate, always

    Cost per attempt is an engineering number. Cost per successful outcome is the business number. The gap between them is money spent on runs that resolved nothing.

  3. 3
    Caching is the largest free lever, with two edges

    Reads at 0.1× and five-minute writes at 1.25× of base input. Below the minimum cacheable prefix it does nothing and says nothing. At a low hit rate it costs more than not caching.

  4. 4
    Containment is not an outcome

    An agent that refuses to escalate scores perfectly on it. Instrument the thing that tells you the customer’s problem ended, before you publish the number that says the conversation did.

Sources

Every source in this lesson

Primary sources wherever one exists. Where a claim is contested or vendor-reported, the lesson says so at the point it is made.

Paper
  • Farmer.Chat: Scaling AI-Powered Agricultural Services for Smallholder FarmersarXiv 2409.08916

    Singh et al. Roughly 75% of user questions answered, with the unanswered quarter broken down as 66% content gaps, 23% out of context, 11% out of collection. A published denominator — which is what a cost-per-successful-outcome metric needs and what almost nobody reports.

Read
  • How we built our multi-agent research systemAnthropic

    13 June 2025. “Agents typically use about 4× more tokens than chat interactions, and multi-agent systems use about 15× more tokens than chats”, and the consequence: “multi-agent systems require tasks where the value of the task is high enough to pay for the increased performance.”

  • The New Business of AI (and How It’s Different From Traditional Software)a16z

    Martin Casado and Matt Bornstein, 16 February 2020. Gross margins “often in the 50-60% range — well below the 60-80%+ benchmark for comparable SaaS businesses”, with “as much as 25% or more of revenue” going to cloud. Written before this generation of models and about a different cost curve; the mechanism has aged better than the numbers.

  • Building A Generative AI PlatformChip Huyen

    25 July 2024. “Cache is perhaps the most underrated component of an AI platform.” Distinguishes prompt cache, exact cache and semantic cache, which are three different margin levers with three different correctness risks.

  • Klarna AI assistant handles two-thirds of customer service chats in its first monthKlarna, 27 Feb 2024

    The company release as distributed on the wire, dated NEW YORK, 27 February 2024 — klarna.com’s own copy of the page renders empty to a fetcher, so this is the accessible primary. 2.3 million conversations, two-thirds of chats, the “equivalent of 700 full-time agents”, 11 minutes to under 2, a projected $40m profit improvement for 2024. Every headline figure is a volume or a duration; none is an outcome measured after the customer left.

  • Klarna Rethinks AI Cost-Cutting Plan With Call for Real PeopleBloomberg, 8 May 2025

    Siemiatkowski: “cost unfortunately seems to have been a too predominant evaluation factor when organizing this, what you end up having is lower quality.” Paywalled; quote and date confirmed by search across several outlets. Secondary coverage of this reversal is badly distorted — go to these two sources only.

  • Building AI Agents for 131 Million CustomersBuilding Nubank

    The metric move this lesson argues for, in production: “to scale, you must pivot to TNPS (Transactional Net Promoter Score) — measuring the specific AI interaction immediately”, with an auditor LLM scoring every conversation. An outcome metric attached to a transaction, not a volume counter.

  • Building Effective AI AgentsAnthropic

    “Agentic systems often trade latency and cost for better task performance, and you should consider when this tradeoff makes sense.” The trade is stated by the people selling the tokens, which is worth noticing.

  • Gartner Predicts Over 40% of Agentic AI Projects Will Be Canceled by End of 2027Gartner, 25 June 2025

    An analyst prediction rather than a measurement. Its first named cause is escalating cost — which is a unit-economics failure discovered late, not a modelling failure.

Docs
  • Prompt cachingClaude docs

    The three multipliers the margin argument rests on, verbatim: “5-minute cache write tokens are 1.25 times the base input tokens price”, “1-hour cache write tokens are 2 times”, and “cache read tokens are 0.1 times the base input tokens price”. Also the minimum cacheable prefix, which is why caching does nothing for short prompts.

  • Plans & pricingClaude

    Where to get a current per-million-token figure to type into the calculator above. Prices in this lesson are deliberately round illustrative defaults, not quotes — model prices move, and a lesson that hardcodes one is wrong within a quarter.

Lesson 26
Team and org design
Lesson 28
Governance and the decision to stop