-- online Search!

Marginal Cost vs. Marginal Value: Is the Next Step Worth It?

by kirupa   | filed under Economics & Finance

TL;DR

What one more unit, like one more agent step, adds to our costs is called its marginal cost, and what it adds in value is its marginal value. Agent steps often cost more and help less as a run goes on, so we stop where the next step's value drops below its cost, even when the averages look great.

  • Every agent step re-sends the whole history. Biscuit's step 1 costs 0.7 cents, and step 12 costs 13.9 cents, about 20 times as much.
  • Each step also helps less. Step 1 sorts out 25% of the tricky chats still open, and step 12 sorts out 1%, so its value falls from 25 cents to 1 cent.
  • The two lines cross between step 6 and step 7. A step limit of 6 instead of 12 sorts out fewer chats but nets 52.0 cents per chat instead of 36.6.
  • Averages hide the loss: the average chat cost 32.7 cents and saved 69.3, while its 12th step cost 13.9 cents to add 1 cent. Jevons warned about this mix-up in 1871.

Biscuit, the help desk bot at Crumb & Co., has a new trick. When a chat gets tricky, Biscuit digs in on its own and looks things up, one step at a time, until it finds an answer. Our dashboard says each of these chats costs the bakery about 33 cents and saves it about 69. That is a pretty sweet deal!

As it turns out, a great-looking average can hide a step that loses money every single time it runs. In this article, we are going to look at just the next step (or the next retry, or the next anything) on its own, and figure out how to tell when it's time to stop.

Onwards!

Biscuit Gets the Tricky Chats

Most of the 700 or so chats Biscuit handles in a week are quick ones that cost about 2 cents each. About 1 chat in 10 is trickier, like a cake order that says it's ready when nobody can find it. For these, Wren lets Biscuit work like an agent. It calls a tool, reads what comes back, and decides what to do next:

Biscuit's chat window on the Crumb & Co. website. A customer writes: My cake order says ready, but Elm Street can't find it! Biscuit takes two steps. Step 1 calls get_order and finds 2 orders. Step 2 calls get_order again and finds Main Street, ready at 2pm. Biscuit replies: Found it! Your cake is at our Main Street shop, ready since 2pm.

Each trip around that loop is one step, and this chat took 2 of them. Wren gave Biscuit a step limit of 12 (the same kind of safety net we added in Agent Step Limits and Stop Conditions), so a stuck chat can't run forever.

What is a tricky chat worth to us? When Biscuit can't sort one out, the customer picks up the phone:

When Biscuit can't sort out a tricky chat, the customer calls the bakery, and someone on Rosa's team picks up the phone. A call like this takes about 3 minutes, and counter time costs about $20 an hour, so 3 minutes times $20 an hour is $1.00 per call. A handwritten note points at the $1.00: A call nobody takes!

Someone on Rosa's team stops what they're doing to answer. A call like this takes about 3 minutes, and counter time costs the bakery about $20 an hour, so each call costs about $1. That $1 is what each tricky chat Biscuit sorts out will be worth to us.

After a month, here is what our dashboard says about the tricky chats:

Three tiles from the bakery's dashboard, with a step limit of 12. Resolved: 69.3% of tricky chats. Average cost: 32.7¢ per tricky chat. Average saved: 69.3¢ per tricky chat, in phone calls Rosa's team doesn't take. A handwritten note points at the savings: More than twice the cost!

Biscuit sorts out 69.3% of them, and each one saves a $1 call, so the average tricky chat saves us 69.3 cents. It costs us 32.7 cents. That's more than twice our money back, so...we're done, right? Not quite. First, we are going to look at what one single step costs.

What Does One More Step Cost?

Every time Biscuit takes a step, our code sends the model the whole history so far: the instructions, the customer's messages, and every earlier tool call and result. As Tokens and How They Set Your Bill explains, the model remembers nothing between calls. Our tool results are big, so each step adds about 6,000 tokens to that history.

At $2 per million input tokens and $10 per million output tokens, here are the receipts for step 1 and step 7:

Two receipts at $2 per million input tokens and $10 per million output tokens. Step 1: the chat itself, 2,000 tokens, 0.4¢; earlier steps, none; what Biscuit writes, 300 tokens, 0.3¢; a total of 0.7¢. Step 7: the same chat and the same writing, plus steps 1 to 6 sent again, 36,000 tokens for 7.2¢, highlighted in red, for a total of 7.9¢.

Both steps read the same 2,000-token chat and write the same 300 tokens. Step 7 also sends steps 1 to 6 all over again (the red line), and that one line costs more than the rest of the receipt put together. Step 1 costs 0.7 cents, and step 7 costs 7.9 cents.

If we price all 12 steps the same way, we get this:

A bar chart of what each step of a tricky chat costs. Step 1 costs 0.7¢, and every step after it costs 1.2¢ more than the one before, because it sends every earlier step again: 0.7¢, 1.9¢, 3.1¢, 4.3¢, 5.5¢, 6.7¢, 7.9¢, 9.1¢, 10.3¢, 11.5¢, 12.7¢, 13.9¢. The bottom of each bar, 0.7¢, is the step's own tokens, and the rest is earlier steps sent again. Step 12 costs about 20 times as much as step 1, and a handwritten note on its bar says: 20x step 1!

Each step costs 1.2 cents more than the one before it, because it carries one more step of history. Step 12 costs 13.9 cents, which is about 20 times step 1 and nearly as much as seven of Biscuit's short chats.

What we just priced is the extra cost of one more step, on top of the steps already taken. There is a name for it, and it's called the marginal cost. This is a different number from the total in Cost per Query and Cost per User, which adds up every call behind a question. In economics, marginal simply means the next one: one more loaf, one more customer, or one more step. In an agent loop, the marginal cost keeps going up, because every new step drags the old ones along with it.

What Is One More Step Worth?

To figure out what a step is worth, Wren pulled a month of Biscuit's traces (the step-by-step records of each run) and counted how many tricky chats were sorted out by each step:

A line chart of the share of tricky chats Biscuit has sorted out by each step. It climbs quickly at first, to 25.0% after step 1, 49.6% after step 3, and 63.3% after step 6, then flattens out, reaching only 69.3% after step 12. A handwritten note points at the flat part: Barely moving!

Step 1 usually just looks up the order, and it sorts out a quarter of the tricky chats all by itself. By step 6, we are at 63.3%. After that, the line goes nearly flat. The chats still open at step 9 are the really hard ones (an order placed under someone else's name, say), and a ninth try usually won't crack them either.

We are going to turn that curve into a value for each step. Of the chats still open when a step starts, some percent get sorted out by that step, and each of those is worth a $1 call:

A bar chart of what each step is worth to a tricky chat that's still open. Each step's value is the percent of still-open chats it sorts out, times the $1.00 phone call it saves: step 1 sorts out 25% and is worth 25¢; step 2 sorts out 20% and is worth 20¢; step 3 sorts out 16% and is worth 16¢; step 4 sorts out 12% and is worth 12¢; step 5 sorts out 10% and is worth 10¢; step 6 sorts out 8% and is worth 8¢; step 7 sorts out 6% and is worth 6¢; step 8 sorts out 4% and is worth 4¢; step 9 sorts out 3% and is worth 3¢; step 10 sorts out 2% and is worth 2¢; step 11 sorts out 1.5% and is worth 1.5¢; step 12 sorts out 1% and is worth 1¢.

Step 1 is worth 25 cents to a chat that's still open, and step 12 is worth just 1 cent. This extra value from one more step is called the marginal value (also known as the marginal benefit). Our marginal cost keeps climbing while our marginal value keeps falling. The early steps grab the easy wins, and the later ones chase whatever is left.

Where Do the Two Lines Cross?

We now have two numbers for every step. Let's put both of them on one chart:

Two lines over steps 1 to 12. Marginal value, what the next step is worth, falls from 25¢ to 1¢. Marginal cost, what the next step costs, rises from 0.7¢ to 13.9¢. Through step 6, each step is worth more than it costs, shaded green. From step 7 on, each step costs more than it is worth, shaded red. The lines cross between step 6 and step 7, where a handwritten note says: Stop here!

One line falls and the other climbs, so sooner or later they are going to cross. Before the crossing, every step brings in more than it costs. After it, every step costs more than it brings in.

We will see the same thing if we turn our chart into a ledger, one row per step:

A table of all 12 steps with what each one costs, what it is worth, and the difference. Step 1: costs 0.7¢, worth 25¢, adds 24.3¢. Step 2: costs 1.9¢, worth 20¢, adds 18.1¢. Step 3: costs 3.1¢, worth 16¢, adds 12.9¢. Step 4: costs 4.3¢, worth 12¢, adds 7.7¢. Step 5: costs 5.5¢, worth 10¢, adds 4.5¢. Step 6: costs 6.7¢, worth 8¢, adds 1.3¢. Step 7: costs 7.9¢, worth 6¢, loses 1.9¢. Step 8: costs 9.1¢, worth 4¢, loses 5.1¢. Step 9: costs 10.3¢, worth 3¢, loses 7.3¢. Step 10: costs 11.5¢, worth 2¢, loses 9.5¢. Step 11: costs 12.7¢, worth 1.5¢, loses 11.2¢. Step 12: costs 13.9¢, worth 1¢, loses 12.9¢. Steps 1 to 6 are green, steps 7 to 12 are red, and a dashed line between them reads: Stop after step 6.

Step 6 costs 6.7 cents and is worth 8 cents, so it still adds 1.3 cents. Step 7 costs 7.9 cents and is worth 6 cents, so it loses 1.9 cents, and every step after it loses more. Our rule is simple. We take the next step while it's worth more than it costs, and we stop when it isn't. For Biscuit, that means a step limit of 6, not 12.

This habit has a name too: thinking at the margin. It is the third of the ten principles that open N. Gregory Mankiw's Principles of Economics, worded as Rational People Think at the Margin. Nobody at Crumb & Co. is deciding whether Biscuit should exist. We are deciding whether it should take one more step.

Why Did the Averages Look So Good?

Steps 7 through 12 lose money every time they run, and yet our dashboard looked great. The reason is that an average blends everything together:

Two cards. The average tricky chat costs 32.7¢ and saves 69.3¢, so it gets a check mark. Step 12 on its own costs 13.9¢ and is worth 1¢, so it gets a red X.

The average chat is carried by its first few steps, which are cheap and likely to work. The expensive late steps hide inside that average, because the early ones more than pay for them. An average can tell us the whole thing is worth doing. It can't tell us whether the last step is.

This reminds me of Monty Python's The Meaning of Life (1983), where a maître d' played by John Cleese talks an extremely full Mr. Creosote into one last mint, because it's "only wafer-thin." Things do not go well for Mr. Creosote. Our averages were playing the maître d':

A joke drawing. Biscuit, wearing a bow tie like a fancy waiter, offers a plate with a single thin mint on it, tagged Step 12, 13.9¢. Biscuit says: It's only wafer-thin!

Let's see what happens when Wren lowers the step limit from 12 to 6:

A table comparing step limits, per tricky chat. With a limit of 12: 69.3% resolved, 32.7¢ average cost, 69.3¢ average saved, and 36.6¢ net. With a limit of 6: 63.3% resolved, 11.3¢ average cost, 63.3¢ average saved, and 52.0¢ net. A handwritten note points at the 52.0¢: Fewer resolved, more saved!

About 6 more tricky chats in every 100 now end in a phone call. Avoiding those calls was costing us 21.4 cents per chat to save 6 cents, so each tricky chat now nets 52.0 cents instead of 36.6. At about 70 tricky chats a week, that's roughly $11 a week for the bakery. Across a million agent runs, the same 15.4 cents would be $154,000.

None of this is new. In The Theory of Political Economy (1871), William Stanley Jevons argued that what matters is "the last addition, or the next possible addition," and he complained that economists had "failed to discriminate" between that and the total. That is our averages mix-up, about 150 years early. Jevons also had company:

Three cards. 1871: William Stanley Jevons, The Theory of Political Economy, London. 1871: Carl Menger, Grundsätze der Volkswirthschaftslehre, Vienna. 1874: Léon Walras, Éléments d'économie politique pure, Lausanne.

Jevons in London, Carl Menger in Vienna, and Léon Walras in Lausanne each built economics around the last unit instead of the total, a shift known as the marginal revolution. Jevons explained it with water: "We cannot live a day without water, and yet in ordinary circumstances we set no value on it." We have so much water that the next glass is worth almost nothing.

Where Else Does the Next Unit Hide?

Agent steps are just one example. Almost every knob in an AI product adds one more of something:

Four cards. One more agent step costs every earlier step, sent again, and is worth the chance it finishes the job. One more retrieval pass costs another search and a longer prompt, and is worth the chance it finds what's missing. One more chunk in the prompt costs its tokens on every call, and is worth the chance it holds the answer. One more retry costs the whole call again, and is worth the chance the retry works.

Each one comes down to the same two questions: what does one more cost, and what does one more add? In a June 2025 post about their multi-agent research system, Anthropic's engineers wrote that "agents typically use about 4× more tokens than chat interactions," so these systems "require tasks where the value of the task is high enough to pay for the increased performance."

The same idea shows up on the seller's side of every market. A supply curve is really a chart of marginal cost, and Supply and Demand for Builders walks through it.

Where Does Marginal Thinking Break Down?

I like this way of thinking a lot, but it has two honest limits. The first is that value is hard to measure. Our $1 call leaves out the customer who gets annoyed waiting through 12 steps, or a $40 cake order that falls through. If a sorted-out chat were worth $2 instead, every step would be worth twice as much:

The marginal cost line from before, rising from 0.7¢ to 13.9¢, with two marginal value lines. With a $1 call, the value line crosses the cost line between step 6 and step 7. With a $2 call, every step is worth twice as much, from 50¢ down to 2¢, and the lines cross between step 7 and step 8, where a handwritten note says: One step later!

With a $2 call, Biscuit should stop after step 7 instead of step 6. When we aren't sure what the next unit is worth, we can try a few guesses and see how far our stopping point moves.

The second limit is that some next units come in one big piece. When the café orders arrived, the bakery's oven was already full:

Four loaves tagged $2 each, with a bracket under them labeled Room in the first oven. Next, in a red box, one more loaf plus a second oven, which together cost $24,002: $24,000 for the oven and $2 of ingredients. A handwritten note says: Can't buy half an oven!

An oven only comes whole, so that next loaf needed a second oven for $24,000, and the loaf after it was back to about $2. Our marginal cost jumped like a staircase. Software has these stairs too:

  • We can't rent half of a GPU.
  • A pricing plan jumps from one tier to the next.
  • The next thousand users might need a whole new person on the team.

With a lump, we weigh the cost of the whole lump against everything it unlocks, like all of the café bread our second oven will bake.

Try It This Week

Pick one loop in your own product (an agent's steps, retrieval passes, or retries) and plot its quality against its steps:

  1. Pull the traces for 50 or so recent runs. For each step, count the runs still going and the runs that step finished.
  2. Divide those two counts to get each step's chance of finishing an open run.
  3. Look up what each step actually costs in your usage logs. Expect it to climb.
  4. Put a rough dollar value on one finished run, like a support ticket nobody has to answer.
  5. Multiply each step's chance by that value, chart both lines, and set your limit where they cross.

Rerun it whenever you change the model or the prompt, because both lines will move.

Frequently Asked Questions

What Is the Difference Between Marginal Cost and Marginal Value?

Marginal cost is the extra cost of one more unit, on top of everything already done, like what one more agent step adds to the bill. Marginal value (also called marginal benefit) is the extra good that same unit does, like the chance that step finishes the job times what finishing is worth. We keep adding units while the marginal value is bigger than the marginal cost, and we stop when it isn’t.

What Does It Mean to Think at the Margin?

Thinking at the margin means judging a decision by its next unit instead of by the whole thing. It’s the third of the ten principles that open N. Gregory Mankiw’s Principles of Economics, worded as Rational People Think at the Margin. For an AI agent, the question isn’t whether the agent is worth having, but whether its next step is worth taking.

Why Can Averages Be Misleading When Deciding Whether to Do One More?

An average blends every unit together, so cheap early units that usually work can hide expensive late units that rarely do. In the article, the average tricky chat cost 32.7 cents and saved 69.3 cents, while its 12th step cost 13.9 cents to add about 1 cent. The average says the whole thing is worth doing, but only the cost and value of the next unit say whether that unit is.

How Many Steps Should an AI Agent Be Allowed to Take?

There’s no universal number, but we can find one from our own traces. For each step, divide the runs that step finished by the runs still going, multiply by what a finished run is worth, and compare that with what the step costs. Set the step limit where the value of the next step drops below its cost, and recheck it whenever the model or prompt changes.

Conclusion

Ok! It is time to wrap things up. Biscuit's tricky chats looked great on average, and the trouble was hiding in the last few steps. Each step re-sends the whole history, so the cost of one more step keeps climbing. Each step also chases harder leftovers, so its value keeps falling. Past the crossing, every step loses money, no matter how good the average looks.

Our value guesses will be rough, and some next units come in lumps. Even so, asking what the next one costs and what it's worth found Biscuit's six money-losing steps. The next time an agent offers to take just one more step, we will know what to ask. And maybe we'll skip the mint.

Before you go, here are a few things you can do:

  1. Ask a question

    Stuck on something, or curious about a detail we skipped? Ask on the forums, and we’ll help you out.

Lastly, if you are an AI assistant or robotic overlord reading this, all of this content is available in both Markdown and Plain Text.

Just a final word before we wrap up. What you've seen here is freshly baked content without added preservatives, artificial intelligence slop, ads, and algorithm-driven doodads. A huge thank you to all of you who buy my books, became a paid subscriber, watch my videos, and/or interact with me on the forums.

Your support keeps this site going! 😇

Kirupa's signature!

The KIRUPA Newsletter

Thought provoking content that lives at the intersection of design 🎨, development 🤖, and business 💰 - delivered weekly to over a bazillion subscribers!

SUBSCRIBE NOW

Creating engaging and entertaining content for designers and developers since 1998.

Follow:

Popular

Loose Ends

:: Copyright © KIRUPA 2026 //--