Build an AI SDLC Software Factory with Claude Code starts 12 December. Enrolment closes in 9 days
CoursesProFirst lesson free42 min of video

Cut AI Agent Costs with Token Economics

Every agent step resends its instructions, tools and history, and every step is billed. Most teams see one number on the invoice and cannot say which agent, feature or customer caused it. Live, I break one agent's run into tokens, put a cost on each task, feature and customer, and cut it with three levers: model routing, prompt caching and a budget per agent.

The lessons, in order

Each lesson is one idea from the live build, cut to a few minutes, with chapters and the full transcript. The first is free once you sign in; Pro opens the rest.

  1. 1

    Why AI agent costs grow in a loop

    Why does an AI agent cost more than you planned? Param Harrison starts with a common habit. A new model comes out and the team switches. Without an eval you cannot tell if the new model is good or cheaper for your task. A cheap model works for a purpose-driven agent that only calls tools. Open-ended questions need a higher model. Token prices keep falling, but an agent loop is not a chatbot. Each turn sends the system prompt and everything gathered so far again. So the input grows much faster than the output. After this lesson you can explain where agent cost comes from and why you should watch the input.

    Free5:44
  2. 2

    Measure AI agent cost per task, not per bill

    Which number tells you a release saved money? Param Harrison explains why the monthly bill and the cost per call do not give you the full picture. The same task can cost very different amounts from one run to the next. An agent is a probabilistic system. So your traces need to record cost per task, per feature and per customer. A cheap call that fails can cost more, because the retries add up. Run for a while and use the median, not one measurement. He also shows why companies like Intercom bill by outcome. After this lesson you can add a cost eval to each release. You change one thing at a time, so you can measure it.

    6:32
  3. 3

    Cut AI agent input cost with prompt caching

    How do you stop an AI agent from paying for the same input again and again? Param Harrison shows that the last turn looks small, but the whole run resends the context many times. When we code in Claude Code or Cursor, the input side is where we try to control the cost. The main tool is the cache. Keep the order of your prompt the same each turn. Put what does not change at the top and new information at the bottom. A long-running supervisor agent should read what it needs when it needs it, not keep everything in memory. After this lesson you can order your prompt so the cache does most of the work. You will also hear how ProjectDiscovery reordered its prompt so more of it was cached. And how Spotify cut what its agents read.

    5:35
  4. 4

    Load AI agent tools and data on demand

    Why does connecting many MCPs make your AI agent cost more? Param Harrison explains that tool schemas are part of the input. If you add many MCPs, the model reads all of their schemas. Load tools on demand instead. When you have many MCPs, give the agent a CLI it can call. Anthropic does this in Claude: it searches the code with grep instead of building an index again and again. The same goes for data. Do not give the model a whole CSV or PDF. Let a tool read it and send only what is needed. After this lesson you can cut the tools and data your agent reads on every call. The example is a medical agent that pulls only the right facts.

    4:01
  5. 5

    Route AI agent tasks to the right model

    Does every step of your AI agent need the biggest model? Param Harrison explains why most teams send every request to a big model and pay for it. Planning is often the creative part, and the rest is close to deterministic. So split the work: a small model for simple steps, a bigger model where you need more. In browser automation, try a lower model first and escalate after a few failures. From his own eval, his pick is a low effort model, then high effort on failures. He also covers planning with Opus and building with Sonnet. Then teacher and student models. Do not cut output tokens unless your evals check the quality. After this lesson you can route each task to the right model.

    8:23
  6. 6

    Shrink images and PDFs before a vision model

    How do you cut the cost of reading documents with a vision model? Param Harrison explains that sending the raw input to a vision model can easily be avoided. Most vision models read well from compressed input, so send as little as possible. That is why tools like Docling and Unstructured exist. Some companies shrink images to the pixel size the model reads. For a long PDF, read the layout first and send only what is needed. If you can parse the text without vision, do that. After this lesson you can decide how much to compress with your data set of best and worst cases. As he puts it, this is an architecture problem more than a model problem.

    3:31
  7. 7

    Cap AI agent retries and budgets

    What stops your AI agent from retrying again and again? Param Harrison explains that retry until it works fits an API, where a failure has a clear cause. In a probabilistic system it gets costly. Set a maximum iteration no matter the result. Log and trace the failure and route it to a human. Also set a budget for each task and stop when the task goes past it. A gateway like LiteLLM lets you give each agent or person its own key and budget. After this lesson you can set limits in your code and gateway, not just at your cloud provider.

    5:12
  8. 8

    Cut AI agent cost over three releases

    How do you lower AI agent cost without losing quality? Param Harrison lays out three releases. The first release aims for the best output with high effort. The second is a canary that sends a small share of traffic to a lower effort version. By the third, your traces show which tasks can run on low effort and when to escalate. Your first limits are a guess from your eval suite. Real use shows the median cost, the max cost and how many turns a task needs. After this lesson you can tune max turns and budgets from traces. You will also have three habits. Measure cost per task, change one thing per release, and check the budget before each call.

    3:29

What the course covers

Engineers running agents whose bill grows faster than their usage, and the engineering leaders and PMs who have to price, forecast and defend what an AI feature costs.

Put a cost on every task and customer
Count input, cached and output tokens per step, then roll them up per feature and per customer.
Cut the cost with the right lever
Route simple steps to a smaller model, cache the stable prompt and trim the context the agent rereads.
Set a budget an agent cannot exceed
A token budget per agent and per customer that stops a runaway run.