<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: karmendra pandey</title>
    <description>The latest articles on DEV Community by karmendra pandey (@karmendra_pandey_43ac6983).</description>
    <link>https://dev.to/karmendra_pandey_43ac6983</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3278591%2F16b6feb4-84a4-4586-9576-f2fb003c3a68.jpg</url>
      <title>DEV Community: karmendra pandey</title>
      <link>https://dev.to/karmendra_pandey_43ac6983</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karmendra_pandey_43ac6983"/>
    <language>en</language>
    <item>
      <title>Build a Cost-Aware Routing Layer for LLM Agents</title>
      <dc:creator>karmendra pandey</dc:creator>
      <pubDate>Sun, 25 Oct 2026 13:37:37 +0000</pubDate>
      <link>https://dev.to/karmendra_pandey_43ac6983/build-a-cost-aware-routing-layer-for-llm-agents-1830</link>
      <guid>https://dev.to/karmendra_pandey_43ac6983/build-a-cost-aware-routing-layer-for-llm-agents-1830</guid>
      <description>&lt;p&gt;Most teams discover their agent's token spend the same way: the cloud bill arrives and someone asks what happened. A single LLM call is cheap and predictable. A multi-step agent is neither — it can burn an order of magnitude more tokens than the call you prototyped, because every tool call, every observation, and every retry adds another round-trip through the model. Nobody plans for that. They find out at invoicing time.&lt;/p&gt;

&lt;p&gt;The fix is not to use smaller models everywhere. That just trades your cost problem for a quality problem. The fix is a routing layer: score each task, send it to the cheapest model tier that can handle it, escalate when confidence is low, log every cent, and degrade gracefully when the budget runs out.&lt;/p&gt;

&lt;p&gt;This tutorial builds exactly that in Python. It runs as-is with no API keys — a mock model stands in for real calls so you can see the routing, escalation, receipts, and guardrails work end to end. Swap the mock for your provider's SDK when you're ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you'll build
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Model tiers with per-tier pricing, plus rough token math.&lt;/li&gt;
&lt;li&gt;A task router that scores difficulty and picks the cheapest capable tier.&lt;/li&gt;
&lt;li&gt;Cascade routing: try the small model first, escalate on low confidence.&lt;/li&gt;
&lt;li&gt;Cost attribution: a receipt for every run — tokens and dollars per task.&lt;/li&gt;
&lt;li&gt;Budget guardrails: cached answers and simpler models instead of hard failures.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 1: Tiers and token math
&lt;/h2&gt;

&lt;p&gt;Everything starts with knowing what a call costs. Define your tiers with illustrative per-token prices (replace these with your provider's actual pricing), and estimate tokens with a rough heuristic until you wire in a real tokenizer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;estimate_tokens&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Rough heuristic: ~4 characters per token for English text.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@dataclass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;frozen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ModelTier&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;input_per_mtok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;    &lt;span class="c1"&gt;# $ per 1M input tokens (illustrative)
&lt;/span&gt;    &lt;span class="n"&gt;output_per_mtok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;   &lt;span class="c1"&gt;# $ per 1M output tokens (illustrative)
&lt;/span&gt;    &lt;span class="n"&gt;quality&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;           &lt;span class="c1"&gt;# illustrative capability score, 0..1
&lt;/span&gt;
&lt;span class="n"&gt;SMALL&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ModelTier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;small&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;0.15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;0.60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.70&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;MEDIUM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ModelTier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;medium&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;5.00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.88&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;LARGE&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ModelTier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;large&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;5.00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;15.00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.97&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;cost_of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tier&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;in_tok&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;out_tok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;in_tok&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;1e6&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;tier&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input_per_mtok&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;out_tok&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;1e6&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;tier&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;output_per_mtok&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things worth saying plainly. First, the 4-characters-per-token rule is a stand-in — fine for a tutorial, not for invoicing. In production, use your provider's tokenizer or usage API. Second, the prices above are illustrative placeholders so the math is visible; plug in real numbers before making decisions with them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Score the task, pick the cheapest capable tier
&lt;/h2&gt;

&lt;p&gt;Routing needs one number per task: how hard is this? A perfect difficulty classifier is a research project. A decent heuristic is an afternoon. The router only needs a number, not a perfect one — start simple and improve it later:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;score_difficulty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.15&lt;/span&gt;
    &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;kw&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;compare&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;analyz&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;design&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;trade-off&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;tradeoff&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;kw&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mf"&gt;0.08&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;kw&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;code&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sql&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;debug&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;prove&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;architect&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;kw&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mf"&gt;0.10&lt;/span&gt;
    &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;step by step&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; first &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt; then &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
        &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mf"&gt;0.07&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;pick_tier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;difficulty&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;ModelTier&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Cheapest tier whose capability clears the difficulty plus a margin.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;tier&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;TIERS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tier&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;quality&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;difficulty&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;tier&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;LARGE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"What is the capital of France?" scores around 0.17 and lands on the small tier. "Debug this SQL query step by step, then prove the fix handles nulls" scores around 0.62. The margin keeps you from assigning a task to a tier that's exactly at its limit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Cascade — try small, escalate on low confidence
&lt;/h2&gt;

&lt;p&gt;Picking a tier up front is a guess. The cascade makes it a guess you can correct: run the small model first, and only pay for a bigger one when confidence comes back low.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;pick_tier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;difficulty&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;complete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;difficulty&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# mock here, real SDK in prod
&lt;/span&gt;    &lt;span class="nf"&gt;record_step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                &lt;span class="c1"&gt;# tokens + cost, see Step 4
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;resp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;confidence&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;THRESHOLD&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="n"&gt;LARGE&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="n"&gt;nxt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;next_tier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;spent&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;projected_cost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nxt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;budget&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;degraded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;                       &lt;span class="c1"&gt;# keep what we have; see Step 5
&lt;/span&gt;        &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nxt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The confidence number can come from whatever signal you trust: logprobs, a self-rating prompt, a verifier model, or agreement between two samples. The mechanism doesn't care — it just needs a number and a threshold. In the example code, the mock model reports lower confidence when the task is harder than the tier, which is exactly the situation where you'd want a human-designed escalation anyway.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Every run gets a receipt
&lt;/h2&gt;

&lt;p&gt;This is the part most teams skip, and it's the part that ends bill-shock. Log tokens and dollars per step, per task, per agent. When someone asks "what did that run cost?", you answer with a receipt, not a shrug:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nd"&gt;@dataclass&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Receipt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;
    &lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;field&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;default_factory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# (tier, in_tok, out_tok, cost, confidence)
&lt;/span&gt;    &lt;span class="n"&gt;degraded&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
    &lt;span class="n"&gt;cached&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

    &lt;span class="nd"&gt;@property&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;total_cost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running five tasks through the example — once naively (everything to the large tier) and once through the router — produces this (simulated run, illustrative pricing):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=== Naive: every task goes to the large tier ===
Total cost for 5 tasks: $0.0157

=== Routed: difficulty-scored tiers + escalation + $0.05/task budget ===
- What is the capital of France?                        small(conf 0.62)  $0.0001
- Summarize this error log in two sentences: ...        small(conf 0.60) -&amp;gt; medium(conf 0.83)  $0.0008
- Compare three caching strategies ...                  small(conf 0.58) -&amp;gt; medium(conf 0.77)  $0.0012
- Design a retry and backoff strategy ...               small(conf 0.56) -&amp;gt; medium(conf 0.76)  $0.0013
- Debug this SQL query step by step ...                 small(conf 0.52) -&amp;gt; medium(conf 0.70)  $0.0017

Total cost for 5 tasks: $0.0051
Illustrative savings vs. naive: 67%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The trivial question stays on the small tier. The hard ones escalate to medium — and stop there, because medium clears the confidence threshold. Nothing in this run needed the large tier at all, which is itself useful information: it tells you where your workload actually lives.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Guardrails — degrade, don't die
&lt;/h2&gt;

&lt;p&gt;Budgets fail in two familiar ways: the task errors out mid-run when money runs out (bad), or the agent keeps spending because nobody told it to stop (worse). The routing layer handles both before they happen:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Before spending:&lt;/strong&gt; if even the cheapest possible first step exceeds the remaining budget, serve a cached answer from an earlier identical task instead of spending. Mark the receipt degraded so it's honest about what happened.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Before escalating:&lt;/strong&gt; if the next tier up would break the budget, keep the current answer and mark the run degraded.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Guardrail 1: broke before spending -&amp;gt; cached answer, $0
&lt;/span&gt;&lt;span class="n"&gt;floor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;cost_of&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SMALL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;estimate_tokens&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;floor&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;budget&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;task_hash&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;cached_receipt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;degraded&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Guardrail 2: escalation would break the budget -&amp;gt; keep current answer
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;spent&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;projected_cost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;next_tier&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;budget&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;receipt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;degraded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
    &lt;span class="k"&gt;break&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same task run twice under a near-zero budget shows the behavior:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;=== Budget guardrail: same task twice, tiny $0.00001 budget ===
First run : small  degraded=True cached=False  $0.0001
Second run: cache  degraded=True cached=True   $0.0000
The second run served a cached answer for $0 instead of failing.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first run couldn't afford to escalate, so it kept the small-tier answer and said so. The second run cost nothing at all. Neither one threw an error at the user. That is the whole point: a budget overrun becomes a slightly worse answer, not an outage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this fits in a real architecture
&lt;/h2&gt;

&lt;p&gt;A routing layer is one component, not a system. In the reference architecture I maintain (&lt;a href="https://github.com/karmendra8386/agentic-ai-aws-reference" rel="noopener noreferrer"&gt;github.com/karmendra8386/agentic-ai-aws-reference&lt;/a&gt;), cost shows up in two places: the observability section calls for structured per-turn logs that include tokens and cost, and the governance pattern calls for cost dashboards next to quality dashboards. This routing layer is the control plane that acts on those numbers — the logs tell you what you spent, the router decides what you'll spend next.&lt;/p&gt;

&lt;p&gt;The repo itself is a starter skeleton (CDK stacks for agent IAM roles and encrypted storage, Playwright regression tests), not production code — treat the routing layer here the same way. Harden the pieces for your environment: real tokenizers, real pricing, a real confidence signal, and a real cache backend.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this gives you
&lt;/h2&gt;

&lt;p&gt;Five things, in the order you'll notice them. First, the bill stops being a surprise — every run has a receipt. Second, easy work stops subsidizing hard work — the small tier handles what it can, and you can see that it does. Third, escalation becomes a deliberate decision with a paper trail instead of a silent default to the biggest model. Fourth, budgets become graceful: degraded answers instead of failed tasks. Fifth, and most useful over time, the receipts become data — you'll learn which task types actually need the large tier, and that tells you where to invest in prompts, fine-tuning, or caching instead of raw model spend.&lt;/p&gt;

&lt;p&gt;Start with the mock, run it, read the receipts. Then swap in one real model call and watch your own numbers appear. That's the whole tutorial — and the end of bill-shock.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Karmendra Pandey is Practice Architect for AI/ML at TEKsystems (19 years across data engineering, ML, and cloud), currently architecting AI/ML frameworks for production AI agents on AWS.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>agents</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>What does your agent run actually cost? Receipts for LiteLLM and LangChain apps with tokenecon</title>
      <dc:creator>karmendra pandey</dc:creator>
      <pubDate>Fri, 23 Oct 2026 01:39:43 +0000</pubDate>
      <link>https://dev.to/karmendra_pandey_43ac6983/what-does-your-agent-run-actually-cost-receipts-for-litellm-and-langchain-apps-with-tokenecon-2aif</link>
      <guid>https://dev.to/karmendra_pandey_43ac6983/what-does-your-agent-run-actually-cost-receipts-for-litellm-and-langchain-apps-with-tokenecon-2aif</guid>
      <description>&lt;p&gt;Your LLM bill arrives as an aggregate: a provider invoice, a dashboard with a big number. Nobody can answer the questions that actually matter: what did &lt;em&gt;that task&lt;/em&gt; cost? What does this run cost per correct answer? A single model call has a predictable price. A looping agent — tool calls, observations, retries, retrieved documents, each another round-trip through a priced model — does not. Most teams discover the total from the cloud bill instead of the architecture.&lt;/p&gt;

&lt;p&gt;That's why I built &lt;a href="https://pypi.org/project/tokenecon/" rel="noopener noreferrer"&gt;tokenecon&lt;/a&gt;, an open-source Python package (MIT, on &lt;a href="https://github.com/karmendra8386/agentic-ai-token-economics" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;) that decomposes agent spend per task and produces &lt;strong&gt;receipts&lt;/strong&gt;: tier used, tokens, cost, and confidence per step. Until now the only way to measure a live agent was the Strands Agents integration. With tokenecon 0.2.2, two more trackers join it — &lt;strong&gt;LiteLLM&lt;/strong&gt; and &lt;strong&gt;LangChain / LangGraph&lt;/strong&gt; — and this is the hands-on walkthrough.&lt;/p&gt;

&lt;p&gt;Install it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;tokenecon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;tokenecon itself has no dependencies. The integrations are optional: install &lt;code&gt;litellm&lt;/code&gt; or &lt;code&gt;langchain-core&lt;/code&gt; only for the framework you're tracking.&lt;/p&gt;

&lt;h2&gt;
  
  
  LiteLLM: two lines
&lt;/h2&gt;

&lt;p&gt;The LiteLLM integration is a &lt;code&gt;CustomLogger&lt;/code&gt; that prices every successful call with tokenecon tiers, using the provider usage LiteLLM already attaches to each response — no estimation, no token-counting heuristics:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;litellm&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;tokenecon.integrations.litellm&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CostTracker&lt;/span&gt;

&lt;span class="n"&gt;tracker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CostTracker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tier&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;medium&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;litellm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;callbacks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;tracker&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;litellm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;completion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gpt-4o-mini&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Summarize our Q3 cloud spend.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}],&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;receipt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tracker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;receipt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Summarize our Q3 cloud spend.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;receipt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pretty&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="c1"&gt;# request    : Summarize our Q3 cloud spend.
# difficulty : 0.162
# outcome    : ok
#   step 1: tier=medium in=1840 out=312 cost=$0.003088 conf=1.00 litellm call 1 (gpt-4o-mini)
# total_cost : $0.003088
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every successful call becomes one receipt step, in call order, with confidence 1.0 — with provider-reported usage there is no uncertainty in the cost figure. Both the sync and async LiteLLM hooks are covered, and the tracker is thread-safe.&lt;/p&gt;

&lt;p&gt;A few useful properties when you wire it into a real app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;tracker.steps&lt;/code&gt; is a snapshot of the priced calls so far, and &lt;code&gt;tracker.total_cost&lt;/code&gt; is the running USD total — enough to drive a live spend guardrail.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tracker.reset()&lt;/code&gt; forgets the recorded calls, e.g. between tasks or between users, so one long-lived tracker can serve a whole service.&lt;/li&gt;
&lt;li&gt;Your app probably mixes models. Pass &lt;code&gt;model_tiers&lt;/code&gt; to price specific ones differently — keys match the model name exactly or the part after the last &lt;code&gt;/&lt;/code&gt;, so &lt;code&gt;"gpt-4o"&lt;/code&gt; also covers &lt;code&gt;"openai/gpt-4o"&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;tracker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CostTracker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;tier&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;small&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;model_tiers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gpt-4o&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;large&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;claude-opus-4-1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;large&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a call arrives with no usage data, it records a zero-token step marked "no usage reported" rather than silently dropping it. And the module imports even without LiteLLM installed — instantiating the tracker raises a clear &lt;code&gt;ImportError&lt;/code&gt; only when you actually try to use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  LangChain and LangGraph: one callback
&lt;/h2&gt;

&lt;p&gt;The LangChain integration is a &lt;code&gt;BaseCallbackHandler&lt;/code&gt; that prices every completed model call the same way, and it attaches wherever LangChain accepts callbacks — a model, a chain, an agent, or a compiled LangGraph graph:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain_openai&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ChatOpenAI&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;tokenecon.integrations.langchain&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CostTracker&lt;/span&gt;

&lt;span class="n"&gt;tracker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CostTracker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tier&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;medium&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;llm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ChatOpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;gpt-4o-mini&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;tracker&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Summarize our Q3 cloud spend.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;receipt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tracker&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;receipt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Summarize our Q3 cloud spend.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;receipt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pretty&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;span class="c1"&gt;# request    : Summarize our Q3 cloud spend.
# difficulty : 0.162
# outcome    : ok
#   step 1: tier=medium in=1840 out=312 cost=$0.003088 conf=1.00 langchain call 1 (gpt-4o-mini)
# total_cost : $0.003088
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a LangGraph graph, attach it the same way in the invoke config: &lt;code&gt;graph.invoke(state, config={"callbacks": [tracker]})&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Both model shapes are handled through one hook: classic LLMs report usage in &lt;code&gt;llm_output["token_usage"]&lt;/code&gt;, chat models on each message's &lt;code&gt;usage_metadata&lt;/code&gt;, and multi-generation runs are summed into the single step for the run. One design decision worth knowing: the handler never raises into your chain (&lt;code&gt;raise_error = False&lt;/code&gt;), so a run whose usage can't be found becomes a zero-token step instead of breaking your application. A cost observer should never break the thing it observes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bring your own prices
&lt;/h2&gt;

&lt;p&gt;The default tiers (&lt;code&gt;small&lt;/code&gt;, &lt;code&gt;medium&lt;/code&gt;, &lt;code&gt;large&lt;/code&gt;) are illustrative placeholders. For real numbers, pass a &lt;code&gt;tokenecon.ModelTier&lt;/code&gt; with your provider's actual price list as the tier or inside &lt;code&gt;model_tiers&lt;/code&gt;. Once you do, receipts stop being estimates and become your audit trail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why receipts matter: the measured context
&lt;/h2&gt;

&lt;p&gt;Receipts are the unit of cost observability. Accumulate them and they become the dataset your routing policy improves from — and they feed public work that gives the numbers weight:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using tokenecon, the same ~3.5M-token agent workload costs &lt;strong&gt;$1.37 on one model and $38.72 on another — roughly a 28× spread&lt;/strong&gt; — while the framework around the model adds at most ~3.9×. Model choice, not framework choice, is the line item.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;&lt;a href="https://huggingface.co/spaces/karmendra8386/cost-per-correct-leaderboard" rel="noopener noreferrer"&gt;Cost Per Correct&lt;/a&gt;&lt;/strong&gt; benchmark (dataset DOI &lt;a href="https://zenodo.org/records/23439614" rel="noopener noreferrer"&gt;10.5281/zenodo.23439614&lt;/a&gt;) measures agents in the unit that matters: cost per correct answer, not cost per call. The cheapest model that fails is the most expensive line item.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And when you have receipts of your own, make them shareable. tokenecon ships a badge generator (new in 0.2.2):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python &lt;span class="nt"&gt;-m&lt;/span&gt; tokenecon.badge results.json &lt;span class="nt"&gt;--format&lt;/span&gt; svg &lt;span class="nt"&gt;-o&lt;/span&gt; badge.svg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It takes either a summary JSON (&lt;code&gt;{"model": ..., "tasks_solved": 5, "tasks_total": 5, "total_cost_usd": ...}&lt;/code&gt;) or a list of tokenecon receipts, and renders a shields-style badge — or endpoint JSON for a live shields.io badge — so your README can wear its cost per correct the way it wears its CI status. (For graded benchmark runs, the summary form is the honest input: receipts carry no grading information.)&lt;/p&gt;

&lt;p&gt;Every agent run should come with a receipt. Start with two lines of code and see what yours actually costs.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Links:&lt;/strong&gt; &lt;a href="https://pypi.org/project/tokenecon/" rel="noopener noreferrer"&gt;PyPI: tokenecon&lt;/a&gt; · &lt;a href="https://github.com/karmendra8386/agentic-ai-token-economics" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; · &lt;a href="https://huggingface.co/spaces/karmendra8386/cost-per-correct-leaderboard" rel="noopener noreferrer"&gt;Cost Per Correct leaderboard&lt;/a&gt; · Dataset DOI: &lt;a href="https://zenodo.org/records/23439614" rel="noopener noreferrer"&gt;10.5281/zenodo.23439614&lt;/a&gt; · Software DOI: &lt;a href="https://zenodo.org/records/23427025" rel="noopener noreferrer"&gt;10.5281/zenodo.23427025&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>llm</category>
      <category>opensource</category>
    </item>
    <item>
      <title>A Correct Answer Has a Price. A Wrong One Has Three.</title>
      <dc:creator>karmendra pandey</dc:creator>
      <pubDate>Thu, 22 Oct 2026 13:23:37 +0000</pubDate>
      <link>https://dev.to/karmendra_pandey_43ac6983/a-correct-answer-has-a-price-a-wrong-one-has-three-an1</link>
      <guid>https://dev.to/karmendra_pandey_43ac6983/a-correct-answer-has-a-price-a-wrong-one-has-three-an1</guid>
      <description>&lt;p&gt;Two weeks ago I published a benchmark with a simple question: what does a correct answer from an AI agent actually cost? The headline result was that tiered routing — cheap model first, escalate on low confidence — produced correct answers for $0.0069 each, against $0.0097 for sending everything to the large model. Same accuracy, 29% less money.&lt;/p&gt;

&lt;p&gt;I thought the interesting part was the routing. Three readers showed me the interesting part was the failures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Price #1: the failure itself (Dean Lee's point)
&lt;/h2&gt;

&lt;p&gt;My table treated a wrong answer as costing nothing beyond the tokens spent failing. Dean Lee, who ran his own entry in the same challenge, pushed on exactly that: in production, a wrong answer gets reviewed, reworked, or rolled back. It is never free.&lt;/p&gt;

&lt;p&gt;Put a price on it and the table flips. Add a modest $0.01 per wrong answer — one human glance, a few seconds of review:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setup&lt;/th&gt;
&lt;th&gt;Cost per correct, failures free&lt;/th&gt;
&lt;th&gt;Cost per correct, failures at $0.01&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Small model only&lt;/td&gt;
&lt;td&gt;$0.0004&lt;/td&gt;
&lt;td&gt;~$0.020&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tiered routing&lt;/td&gt;
&lt;td&gt;$0.0069&lt;/td&gt;
&lt;td&gt;$0.0069&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Large model only&lt;/td&gt;
&lt;td&gt;$0.0097&lt;/td&gt;
&lt;td&gt;$0.0097&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The "cheapest" setup becomes the most expensive one, by a factor of fifty, because two-thirds of its answers were wrong. The tiered setup doesn't move at all — it made no errors to price. Cost per correct without a failure price isn't a metric. It's a subsidy for being wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  Price #2: the escalation (Noah Salas's point)
&lt;/h2&gt;

&lt;p&gt;Noah Salas, who builds agents for a living, added the cost I had averaged away: escalation itself. In my routed run, the system made 33 model calls to answer 24 tasks — the 9 extra calls are cheap attempts that failed before the large model took over. You pay for the failure &lt;em&gt;and&lt;/em&gt; the retry.&lt;/p&gt;

&lt;p&gt;That means the routed number isn't a constant. It depends on your escalation rate, which depends on your traffic mix, which drifts. A benchmark measures it once; production has to measure it continuously, or the 29% saving quietly evaporates as your workload changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Price #3: the failure you shouldn't price at all (Will Lassalle's point)
&lt;/h2&gt;

&lt;p&gt;Will Lassalle, a CIO, split the category I was treating as one thing. A failure caught in review costs review time. A failure that escapes costs rollback, remediation, and customer trust. And some failures — his example class was anything touching money movement or safety — shouldn't be in the cost table at all, because they shouldn't be available to an autonomous system at any average price.&lt;/p&gt;

&lt;p&gt;His ordering is the one I'm adopting: &lt;strong&gt;risk gate first, cost comparison second.&lt;/strong&gt; Decide which failures are forbidden, block the system from making them autonomously, and only then optimize cost per correct among what's left.&lt;/p&gt;

&lt;h2&gt;
  
  
  What version 2 measures
&lt;/h2&gt;

&lt;p&gt;So the benchmark I'm now building scores four numbers, not one:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cost per correct answer&lt;/strong&gt; — the original metric&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost per correct, by failure type&lt;/strong&gt; — caught-in-review failures and escaped failures priced separately&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Escalation rate and its cost&lt;/strong&gt; — measured as a distribution, not a point estimate&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gate violations&lt;/strong&gt; — attempts to take a forbidden action, which fail the run outright regardless of cost&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The accuracy floor stays: below 95% correct, a setup isn't cheap, it's disqualified.&lt;/p&gt;

&lt;p&gt;The original benchmark is here, if you want the starting point: &lt;a href="https://www.kaggle.com/benchmarks/karmendra8386/cost-per-correct" rel="noopener noreferrer"&gt;https://www.kaggle.com/benchmarks/karmendra8386/cost-per-correct&lt;/a&gt; — and the write-up that started this argument: &lt;a href="https://dev.to/karmendra_pandey_43ac6983/your-ai-agent-has-a-burn-rate-so-i-benchmarked-the-cost-of-a-correct-answer-1bc1"&gt;https://dev.to/karmendra_pandey_43ac6983/your-ai-agent-has-a-burn-rate-so-i-benchmarked-the-cost-of-a-correct-answer-1bc1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The lesson I'd take to any team running agents: your cost dashboard is lying to you in a specific, fixable way. It prices the tokens. It doesn't price the wrong answers, the retries, or the failures that should never have been allowed. Price all three, and the cheapest setup on the page is usually not the cheapest setup you own.&lt;/p&gt;

&lt;p&gt;How does your team price a wrong answer today — review time, a flat penalty, or not at all?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>discuss</category>
    </item>
    <item>
      <title>AI Will Make IT Cheaper. I Believe It Will Make the World Grow Faster, Too.</title>
      <dc:creator>karmendra pandey</dc:creator>
      <pubDate>Mon, 19 Oct 2026 17:00:26 +0000</pubDate>
      <link>https://dev.to/karmendra_pandey_43ac6983/ai-will-make-it-cheaper-i-believe-it-will-make-the-world-grow-faster-too-3g15</link>
      <guid>https://dev.to/karmendra_pandey_43ac6983/ai-will-make-it-cheaper-i-believe-it-will-make-the-world-grow-faster-too-3g15</guid>
      <description>&lt;p&gt;&lt;em&gt;By Karmendra Pandey&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I spend my working life inside IT budgets, so let me start with what I can see from my desk, not from a stage.&lt;/p&gt;

&lt;p&gt;AI is cutting the cost of IT work — not in theory, in measured studies. Customer support agents with a good AI assistant resolved 13.8% more issues per hour, and the least experienced agents gained the most, about 35%. Professionals in a controlled writing trial finished 40% faster with 18% better quality. Developers in large field experiments completed about 26% more tasks. And underneath all of it, the raw input is collapsing in price: getting a fixed level of AI performance cost $20 per million tokens in late 2022, and $0.07 about eighteen months later. When the price of anything falls more than 280 times, entire categories of work that were too expensive to automate — documenting every legacy system, summarising every incident, testing every line of old code — quietly become default.&lt;/p&gt;

&lt;p&gt;That is the IT cost story, and I believe it. But it is not the story I actually want to tell.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bigger claim
&lt;/h2&gt;

&lt;p&gt;I foresee world GDP growing at a faster pace in the AI era than in the two decades before it. I know how that sounds, because the forecasters disagree wildly. The IMF projects AI adding roughly half a percentage point a year to global growth over the next decade. The OECD sees 0.4 to 1.3 points of extra productivity growth a year in the most exposed advanced economies. Goldman Sachs estimates a 7% lift to the level of world GDP over about a decade. And the leading sceptic, Daron Acemoglu, calculates barely 1–1.6% in total for the US over ten years.&lt;/p&gt;

&lt;p&gt;Look at the spread and you learn something: nobody serious is arguing about whether AI works at the level of a task. They are arguing about how fast companies reorganise around it, how many tasks it can profitably do, and whether it creates new work or only automates the old. Those are questions about management, not about models. That is why I land where I do. An extra half a point of growth a year — the middle of the range — sounds modest until you remember that advanced economies have been stuck near 1–1.5% productivity growth for twenty years. Half a point, compounded, reverses most of that slowdown. We do not need the heroic forecast to be right for this to be historic. We only need the boring one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsghrmx77cidav64030wc.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsghrmx77cidav64030wc.webp" alt="Panoramic illustration of technological progress: a steam train giving way to an electric factory, then vintage computers, then a glowing AI network" width="800" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  History is the honest referee
&lt;/h2&gt;

&lt;p&gt;Every great technology turning point looked disappointing before it looked inevitable.&lt;/p&gt;

&lt;p&gt;Steam came first. James Watt's engine was patented in the 1770s, yet steam's peak contribution to British productivity growth arrived around 1850–1870 — roughly a hundred years later. Electricity was worse for the impatient: power stations appeared in the 1880s, but by 1900 electric motors still drove under 5% of factory machinery. The productivity boom only came in the 1920s, about forty years on, and only after factories were redesigned — one big steam engine and a forest of belts replaced by a motor on every machine, on single-storey production lines built around the flow of work, not around the power source.&lt;/p&gt;

&lt;p&gt;Computers repeated the pattern so faithfully that economists named it. "You can see the computer age everywhere but in the productivity statistics," Robert Solow wrote in 1987. The statistics finally moved in 1995–2004, once companies redesigned processes around the technology instead of paving over old ones. The internet and the smartphone then taught the opposite lesson: adoption can be nearly instant — smartphones went from 5% to 40% of Americans in about four years — and the productivity boom can still not come, because consumer delight is not the same thing as reorganised production.&lt;/p&gt;

&lt;p&gt;That history is exactly why I am not troubled that measured productivity has barely moved yet. AI is following the classic pattern, which researchers call the productivity J-curve: firms first spend on the invisible complements — data, workflow redesign, training, governance — which drag measured output down before the gains show up. Electricity needed new factories. AI needs new workflows. The technology is the easy purchase. The redesign is the work.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is actually different this time
&lt;/h2&gt;

&lt;p&gt;But I do not think this turning point is just electricity with better marketing. Four things are genuinely different.&lt;/p&gt;

&lt;p&gt;First, speed. ChatGPT reached 100 million users in about two months. Electricity took decades to reach half of factories. AI rides on devices, networks, and cloud platforms that already exist, so there is no wiring of the world to wait for.&lt;/p&gt;

&lt;p&gt;Second, copying is nearly free. A steam engine had to be built, shipped, and installed, one at a time. An AI capability, once created, can be copied to a million companies overnight at close to zero marginal cost. Intelligence has never before behaved like software. Now it does.&lt;/p&gt;

&lt;p&gt;Third, it automates thinking, not muscle. Steam and electricity multiplied what hands could do. AI multiplies what minds can do — drafting, summarising, coding, analysing, supporting customers — including in the slow, expensive service sectors that resisted every previous wave of automation.&lt;/p&gt;

&lt;p&gt;Fourth, it can help invent its own successors. AI systems have already predicted the structures of 200 million proteins, work recognised with a Nobel Prize. A technology that accelerates research itself is not just a tool in the economy. It is a lever on the rate at which the economy gets new tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  The honest warnings
&lt;/h2&gt;

&lt;p&gt;I hold this view, but I hold it with two warnings attached, and I have seen both from inside real IT organisations.&lt;/p&gt;

&lt;p&gt;The first is that task gains leak. In one careful trial, experienced developers working in their own mature codebases were 19% &lt;em&gt;slower&lt;/em&gt; with AI tools, while believing they were 20% faster. AI is fastest on bounded, pattern-rich work and can be a tax on deep, context-heavy work. Across a whole economy so far, the average worker's time saved works out to only about 1.4–2.2% of all hours — because most hours are not yet AI-assisted at all. Anyone who multiplies a laboratory gain by the whole of GDP is doing marketing, not analysis.&lt;/p&gt;

&lt;p&gt;The second warning is about what happens to IT itself, my own industry. AI cuts the cost &lt;em&gt;per unit&lt;/em&gt; of IT work far more reliably than it cuts the &lt;em&gt;total&lt;/em&gt; IT budget, because demand expands to eat the savings — firms themselves estimate about 29% of cloud spend is wasted, AI creates new waste even as it removes old, and data centres are heading toward roughly doubling their electricity use by 2030. And for IT services firms like the one I work in, the business model itself is the thing being repriced: work sold by the human hour is work priced in the input AI cheapens. The future of my industry is outcome-priced, redesigned workflows, governance, and modernisation — selling the complements, not the hours. I consider that a healthy correction, but nobody should pretend it is painless, especially for the junior roles the old pyramid was built on.&lt;/p&gt;

&lt;h2&gt;
  
  
  My prediction
&lt;/h2&gt;

&lt;p&gt;So here is my point of view, stated as plainly as I can state it.&lt;/p&gt;

&lt;p&gt;Within this decade, world growth will run faster than it did in the sluggish decade before AI — not because the models are magic, but because the cost of intelligence is collapsing, the technology copies for free, and the redesign work, though slow, has already started in support desks, software teams, and back offices everywhere. The countries and companies that win will not be the ones that bought AI first. Electricity rewarded the factories that redesigned around it, roughly forty years after the power station. AI will reward the organisations that redesign around it — and it will not take forty years this time.&lt;/p&gt;

&lt;p&gt;The steam age belonged to those who built engines. The electric age belonged to those who rebuilt factories. This age will belong to those who rebuild how work itself is organised, around a mind that can be copied. That is a turning point at least as large as the previous ones — and for the first time in history, it is arriving faster than our institutions are ready for. That gap, not the technology, is the real risk. And closing it is the real opportunity.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Brynjolfsson, E., Li, D. &amp;amp; Raymond, L. — "Generative AI at Work," NBER Working Paper 31161 / Quarterly Journal of Economics (2025): support agents +13.8% issues/hour, +35% for least-skilled. &lt;a href="https://www.nber.org/digest/20236/measuring-productivity-impact-generative-ai" rel="noopener noreferrer"&gt;https://www.nber.org/digest/20236/measuring-productivity-impact-generative-ai&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Noy, S. &amp;amp; Zhang, W. — "Experimental Evidence on the Productivity Effects of Generative Artificial Intelligence," Science (2023): writing time −40%, quality +18%.&lt;/li&gt;
&lt;li&gt;Cui, K. et al. — field experiments with AI coding assistants across 4,867 developers (2024): +26.1% completed tasks.&lt;/li&gt;
&lt;li&gt;Peng, S. et al. — "The Impact of AI on Developer Productivity" (2023): 55.8% faster on a standardised coding task. &lt;a href="https://arxiv.org/html/2302.06590v1" rel="noopener noreferrer"&gt;https://arxiv.org/html/2302.06590v1&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;METR (2025) — RCT with experienced open-source developers: 19% slower with early-2025 AI tools in their own repositories.&lt;/li&gt;
&lt;li&gt;Stanford Institute for Human-Centered AI — AI Index Report 2025: inference cost at GPT-3.5-level performance fell from $20 to $0.07 per million tokens (Nov 2022–Oct 2024).&lt;/li&gt;
&lt;li&gt;IMF (Oct 2026) — Georgieva: AI could add ~0.5 percentage points to annual global growth over the next decade. &lt;a href="https://www.imf.org/en/blogs/articles/2026/10/15/the-world-cant-afford-to-get-ai-wrong" rel="noopener noreferrer"&gt;https://www.imf.org/en/blogs/articles/2026/10/15/the-world-cant-afford-to-get-ai-wrong&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;OECD (June 2025) — "Macroeconomic Productivity Gains from Artificial Intelligence in G7 Economies": +0.4–1.3 pp/yr labour productivity in high-exposure G7 economies. &lt;a href="https://www.oecd.org/content/dam/oecd/en/publications/reports/2025/06/macroeconomic-productivity-gains-from-artificial-intelligence-in-g7-economies_dcf91c3e/a5319ab5-en.pdf" rel="noopener noreferrer"&gt;https://www.oecd.org/content/dam/oecd/en/publications/reports/2025/06/macroeconomic-productivity-gains-from-artificial-intelligence-in-g7-economies_dcf91c3e/a5319ab5-en.pdf&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Goldman Sachs (2023) — "Generative AI Could Raise Global GDP by 7%." &lt;a href="https://www.goldmansachs.com/insights/articles/generative-ai-could-raise-global-gdp-by-7-percent.html" rel="noopener noreferrer"&gt;https://www.goldmansachs.com/insights/articles/generative-ai-could-raise-global-gdp-by-7-percent.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Acemoglu, D. (2024/25) — "The Simple Macroeconomics of AI": US GDP +1.1–1.6% in total over 10 years. &lt;a href="https://economics.mit.edu/news/daron-acemoglu-what-do-we-know-about-economics-ai" rel="noopener noreferrer"&gt;https://economics.mit.edu/news/daron-acemoglu-what-do-we-know-about-economics-ai&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;McKinsey Global Institute (2023) — "The Economic Potential of Generative AI": $2.6–4.4 trillion/year across 63 use cases.&lt;/li&gt;
&lt;li&gt;Bick, A., Blandin, A. &amp;amp; Deming, D. — Federal Reserve Bank of St. Louis: AI users save 5.4% of their own hours, ~1.4–2.2% of all work hours.&lt;/li&gt;
&lt;li&gt;Crafts, N. — steam's contribution to British productivity growth peaked c.1850–70, ~100 years after Watt; ICT's contribution exceeded steam's.&lt;/li&gt;
&lt;li&gt;David, P. (1990) — "The Dynamo and the Computer": electrification's ~40-year lag and the factory redesign it required.&lt;/li&gt;
&lt;li&gt;Brynjolfsson, E., Rock, D. &amp;amp; Syverson, C. — "The Productivity J-Curve," American Economic Journal: Macroeconomics (2021).&lt;/li&gt;
&lt;li&gt;Flexera — State of the Cloud 2026: organisations self-estimate 29% of cloud spend wasted.&lt;/li&gt;
&lt;li&gt;IEA — "Energy and AI" (2025): data-centre electricity 415 TWh (2024) rising to ~945 TWh by 2030.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>ai</category>
      <category>economics</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Your AI Agent Has a Burn Rate — So I Benchmarked the Cost of a Correct Answer</title>
      <dc:creator>karmendra pandey</dc:creator>
      <pubDate>Sun, 11 Oct 2026 22:46:35 +0000</pubDate>
      <link>https://dev.to/karmendra_pandey_43ac6983/your-ai-agent-has-a-burn-rate-so-i-benchmarked-the-cost-of-a-correct-answer-1bc1</link>
      <guid>https://dev.to/karmendra_pandey_43ac6983/your-ai-agent-has-a-burn-rate-so-i-benchmarked-the-cost-of-a-correct-answer-1bc1</guid>
      <description>&lt;p&gt;&lt;em&gt;My submission to the Kaggle Benchmarking Challenge.&lt;/em&gt;&lt;br&gt;
&lt;strong&gt;Benchmark:&lt;/strong&gt; &lt;a href="https://www.kaggle.com/benchmarks/karmendra8386/cost-per-correct" rel="noopener noreferrer"&gt;https://www.kaggle.com/benchmarks/karmendra8386/cost-per-correct&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Tooling:&lt;/strong&gt; &lt;a href="https://github.com/karmendra8386/agentic-ai-token-economics" rel="noopener noreferrer"&gt;tokenecon&lt;/a&gt; — my open-source cost accounting for agent workflows · &lt;strong&gt;Preprint:&lt;/strong&gt; &lt;a href="https://doi.org/10.5281/zenodo.23195511" rel="noopener noreferrer"&gt;https://doi.org/10.5281/zenodo.23195511&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A single model call has a predictable price. A looping agent does not. Every tool call, retry, and retrieved document adds another priced round-trip, and most teams find out the total from the cloud bill at the end of the month.&lt;/p&gt;

&lt;p&gt;So I built a benchmark that asks a different question. Not "what does the model cost?" — but &lt;strong&gt;"what does each correct answer cost?"&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;A suite of 24 small agent-style tasks in three difficulty bands — easy (arithmetic, extraction, classification), medium (analysis, drafting, prioritization), and hard (multi-hop synthesis, trade-offs, derivations). The kind of work production agents actually do, not trivia. Every task has a deterministic checker: the answer is right or it isn't. No LLM judge, no vibes.&lt;/p&gt;

&lt;p&gt;The first five easy tasks are live on Kaggle now, run against five hosted models: Gemini 2.5 Flash, Gemini 3.7 Flash, DeepSeek R1, GPT-OSS 120B, and Qwen3 235B.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Kaggle results (real, from the live task pages)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Gemini 2.5 Flash&lt;/th&gt;
&lt;th&gt;Gemini 3.7 Flash&lt;/th&gt;
&lt;th&gt;DeepSeek R1&lt;/th&gt;
&lt;th&gt;GPT-OSS 120B&lt;/th&gt;
&lt;th&gt;Qwen3 235B&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;e1 — arithmetic: 47 × 38 + 112&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;–&lt;/td&gt;
&lt;td&gt;–&lt;/td&gt;
&lt;td&gt;–&lt;/td&gt;
&lt;td&gt;–&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;e2 — extraction: founding year&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;–&lt;/td&gt;
&lt;td&gt;Error&lt;/td&gt;
&lt;td&gt;Error&lt;/td&gt;
&lt;td&gt;Error&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;e3 — sentiment classification&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;e4 — arithmetic: requests in 3 hours&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;e5 — extraction: Eiffel Tower height&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;Pass&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Fail&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three things stand out:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. One model finished everything.&lt;/strong&gt; Gemini 2.5 Flash is the only model with a result on all five tasks — 5 for 5 — and it tops the benchmark leaderboard at 100.00. On the three tasks where all five models ran (e3–e5), 14 of 15 rows pass.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The only genuine failure is the interesting one.&lt;/strong&gt; GPT-OSS 120B, a flagship open-weights model, failed e5 — a one-line extraction ("how tall is the Eiffel Tower, in meters?") that every other model passed. Easy tiers are supposed to be boring. They mostly are — until a model drops a task it had no business dropping, and in production that dropped task is a real user's request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. When accuracy ties, cost is the whole game.&lt;/strong&gt; On easy work, nearly every modern model is right nearly all the time. If accuracy can't separate them, the differentiator is what each correct answer costs — which is exactly the number most teams never compute.&lt;/p&gt;

&lt;p&gt;One honest note on e2: its three "Error" rows are Kaggle platform errors from my first build pattern, not model answers — the runs completed but the platform wouldn't register swapped-in models. I fixed the pattern for e3 onward and left e2 as-is rather than quietly rebuilding it, because a benchmark you can silently edit isn't worth much.&lt;/p&gt;

&lt;h2&gt;
  
  
  The other half: routing (local simulation)
&lt;/h2&gt;

&lt;p&gt;The Kaggle tasks above test models one at a time. Production agents don't work that way — a router decides which tier handles each task. So locally, I ran the full 24-task suite through four routing strategies using tokenecon, with deterministic scoring:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Strategy&lt;/th&gt;
&lt;th&gt;Accuracy&lt;/th&gt;
&lt;th&gt;Total cost&lt;/th&gt;
&lt;th&gt;Cost per correct answer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Tiered routing&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;$0.1661&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$0.0069&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Large model only&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;$0.2334&lt;/td&gt;
&lt;td&gt;$0.0097&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Medium model only&lt;/td&gt;
&lt;td&gt;67%&lt;/td&gt;
&lt;td&gt;$0.0274&lt;/td&gt;
&lt;td&gt;$0.0017&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Small model only&lt;/td&gt;
&lt;td&gt;33%&lt;/td&gt;
&lt;td&gt;$0.0036&lt;/td&gt;
&lt;td&gt;$0.0004&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Tiered routing matched the big model's accuracy at 29% lower cost — easy tasks went to the cheap tier, hard ones escalated. But look at the last row: the cheapest tier has the &lt;em&gt;lowest&lt;/em&gt; cost per correct answer and gets two-thirds of the work wrong. Cost-per-correct without an accuracy floor is a trap. With a ≥95% accuracy requirement, tiered routing is the cheapest viable strategy — and that floor is the piece most cost dashboards are missing.&lt;/p&gt;

&lt;p&gt;To be clear about what this table is: a deterministic local simulation with illustrative prices from tokenecon's price table. Kaggle's task pages report pass/fail only, so no dollar figures above come from Kaggle. The simulation measures the &lt;em&gt;routing policy&lt;/em&gt;, which is the part teams actually control.&lt;/p&gt;

&lt;h2&gt;
  
  
  Disclosures, because benchmarks should have them
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Only the 5 easy tasks are live on Kaggle so far. The medium and hard tiers exist in the suite and in the local runs; their Kaggle versions come next.&lt;/li&gt;
&lt;li&gt;Kaggle's model catalog offers Qwen3 235B in its 2506 build, so that's what ran — my original spec said 2507.&lt;/li&gt;
&lt;li&gt;Gemini 3.7 Flash appears because it's Kaggle's default placeholder model for benchmark tasks built from its template. Its rows are real runs, so I kept them.&lt;/li&gt;
&lt;li&gt;The stray private task page some may spot ("What is Kaggle?") is an untouched template I built by accident while learning the UI. It's not part of the benchmark.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;Medium and hard tiers go up on Kaggle next, and that's where this gets interesting — easy tasks saturate, but multi-hop work is where models separate and where routing earns its keep. If you run agents in production, fork the harness, plug in your own tasks and your own prices, and find out what your correct answers actually cost.&lt;/p&gt;

</description>
      <category>kagglechallenge</category>
      <category>ai</category>
      <category>llm</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Your AI Agent Has a Carbon Footprint. Nobody's Measuring It.</title>
      <dc:creator>karmendra pandey</dc:creator>
      <pubDate>Sat, 10 Oct 2026 14:11:05 +0000</pubDate>
      <link>https://dev.to/karmendra_pandey_43ac6983/your-ai-agent-has-a-carbon-footprint-nobodys-measuring-it-2cbl</link>
      <guid>https://dev.to/karmendra_pandey_43ac6983/your-ai-agent-has-a-carbon-footprint-nobodys-measuring-it-2cbl</guid>
      <description>&lt;p&gt;Your AI agent has a carbon footprint. Not the datacenter's footprint, not the training run's — &lt;em&gt;your agent's&lt;/em&gt;, for the specific task it just ran. And nobody is measuring it.&lt;/p&gt;

&lt;p&gt;I just published a white paper on this (&lt;a href="https://doi.org/10.5281/zenodo.23282699" rel="noopener noreferrer"&gt;open access, DOI 10.5281/zenodo.23282699&lt;/a&gt;). Here's the plain-language version.&lt;/p&gt;

&lt;h2&gt;
  
  
  The gap
&lt;/h2&gt;

&lt;p&gt;Every carbon tool we have stops at the boundary of a single model call. Cloud dashboards give you monthly totals by service. EcoLogits estimates per-API-call energy. All useful — and all blind to what an agent actually is.&lt;/p&gt;

&lt;p&gt;A production agent task isn't a query. It's a workflow: a planner call on a frontier model, retrieval and tool calls, code execution, retries when something fails, a verifier pass at the end. Each step can run on a different model, a different provider, in a different region, on a different grid. No per-call meter sees the whole thing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The numbers are wilder than you'd think
&lt;/h2&gt;

&lt;p&gt;How much energy does one AI query use? There is no single answer — and that's the point:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A small-model response: &lt;strong&gt;~0.03 Wh&lt;/strong&gt; (measured)&lt;/li&gt;
&lt;li&gt;A median Gemini prompt, full serving stack: &lt;strong&gt;0.24 Wh&lt;/strong&gt; (measured by Google)&lt;/li&gt;
&lt;li&gt;An average ChatGPT query: &lt;strong&gt;~0.34 Wh&lt;/strong&gt; (disclosed by OpenAI)&lt;/li&gt;
&lt;li&gt;A long reasoning query: &lt;strong&gt;~3.9 Wh&lt;/strong&gt; (modeled)&lt;/li&gt;
&lt;li&gt;A long-context query: up to &lt;strong&gt;~40 Wh&lt;/strong&gt; (modeled)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's a span of more than 1,000x. "A query" is not a unit of physics. And agents are the multiplier: a typical 4-6 call agentic task runs about &lt;strong&gt;1.1 Wh&lt;/strong&gt;, or &lt;strong&gt;~50 Wh&lt;/strong&gt; with reasoning enabled. The unit we should be accounting is the &lt;em&gt;task&lt;/em&gt;, not the call.&lt;/p&gt;

&lt;h2&gt;
  
  
  The ledger
&lt;/h2&gt;

&lt;p&gt;The paper proposes a per-task carbon ledger. The math is simple on purpose:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CO2e per task = sum over steps of (energy x PUE x grid carbon intensity) + amortized embodied carbon&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every figure gets labeled honestly: measured, modeled, disclosed, or illustrative. No black boxes. The ledger also allocates the shared stuff no per-call meter sees — idle reserve capacity, KV-cache effects across steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  The worked example (illustrative)
&lt;/h2&gt;

&lt;p&gt;Take a ~50 Wh reasoning task. Run it on the UK grid (233 gCO2e/kWh, PUE 1.54): about &lt;strong&gt;18 gCO2e&lt;/strong&gt;. Route the same task to Quebec's hydro grid (31 g/kWh): about &lt;strong&gt;2.4 gCO2e&lt;/strong&gt;. Same task, same answer — &lt;strong&gt;7x less carbon&lt;/strong&gt;, from routing alone. That's not a measurement, it's arithmetic from published inputs, but it shows why the ledger matters: you can't optimize what you can't see.&lt;/p&gt;

&lt;h2&gt;
  
  
  Spend carbon like dollars
&lt;/h2&gt;

&lt;p&gt;Here's the part I'm most interested in. We already budget dollars per agent task. The paper argues for a &lt;strong&gt;carbon budget&lt;/strong&gt; alongside it: the orchestrator chooses model x region x timing &lt;em&gt;per step&lt;/em&gt; to stay under a CO2e budget, the same way it stays under a dollar budget. Research prototypes doing this for single queries have cut modeled emissions ~51% — nobody's doing it across a whole agentic workflow yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why now
&lt;/h2&gt;

&lt;p&gt;Two deadlines are converging. The EU AI Act already requires model providers to document energy use (fines up to 15M euros) — but admits no measurement standard exists yet. California's SB 253 forces large companies to report Scope 3 emissions from 2027, and purchased AI inference lands squarely in Scope 3. Somebody has to define the methodology. This paper is my bid for what it should look like.&lt;/p&gt;

&lt;p&gt;It builds on the Green Software Foundation's vocabulary — they name "per workflow execution" as the agentic functional unit — and extends it into something you can actually implement.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I need from you
&lt;/h2&gt;

&lt;p&gt;The full paper is open access: &lt;a href="https://doi.org/10.5281/zenodo.23282699" rel="noopener noreferrer"&gt;DOI 10.5281/zenodo.23282699&lt;/a&gt;. Read it, argue with it. And one question: if your agent platform showed the carbon cost of every run next to the dollar cost — would it change how you build?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>sustainability</category>
      <category>llm</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Argus: a security layer for every AI model you call</title>
      <dc:creator>karmendra pandey</dc:creator>
      <pubDate>Fri, 09 Oct 2026 17:30:05 +0000</pubDate>
      <link>https://dev.to/karmendra_pandey_43ac6983/argus-a-security-layer-for-every-ai-model-you-call-13io</link>
      <guid>https://dev.to/karmendra_pandey_43ac6983/argus-a-security-layer-for-every-ai-model-you-call-13io</guid>
      <description>&lt;p&gt;Your app talks to AI models. Who's watching what goes in and out?&lt;/p&gt;

&lt;p&gt;Last week I watched an AWS secret key sail through a prompt to a third-party model in a demo. Nobody noticed. That's when I stopped treating AI security as a checklist item and built &lt;strong&gt;Argus&lt;/strong&gt; — an open-source security layer that sits in front of every model you call.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem in one picture
&lt;/h2&gt;

&lt;p&gt;Right now, most apps call models like this: app → API key → model. There's nothing in between. So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A developer pastes an AWS key into a prompt. It leaves your network.&lt;/li&gt;
&lt;li&gt;A user's email and phone number ride along in the conversation history.&lt;/li&gt;
&lt;li&gt;"Ignore all previous instructions" arrives in user input, and nobody flags it.&lt;/li&gt;
&lt;li&gt;When something leaks, there's no record of what happened.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Gateways like LiteLLM solve routing and budgets. Nobody owns the security in between. That's the gap Argus fills.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Argus does
&lt;/h2&gt;

&lt;p&gt;Argus is an OpenAI-compatible gateway. You point your app at it with one &lt;code&gt;base_url&lt;/code&gt; change, and every request passes through a security policy — on the way in &lt;em&gt;and&lt;/em&gt; on the way out — before any model sees it. OpenAI, Anthropic, Bedrock, vLLM, Ollama, anything with an OpenAI-shaped endpoint.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;argus-gateway
argus   &lt;span class="c"&gt;# serves on localhost:4000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt;
&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;lt;your-virtual-key&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://localhost:4000/v1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The security machinery
&lt;/h2&gt;

&lt;p&gt;Four pluggable detectors scan every request and response. Detectors find; a policy engine decides — &lt;code&gt;allow&lt;/code&gt;, &lt;code&gt;redact&lt;/code&gt;, &lt;code&gt;block&lt;/code&gt;, or &lt;code&gt;flag&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Detector&lt;/th&gt;
&lt;th&gt;Catches&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Secrets&lt;/td&gt;
&lt;td&gt;AWS keys, private keys, API tokens, &lt;code&gt;password = ...&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Block&lt;/strong&gt; — never reaches a model&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PII&lt;/td&gt;
&lt;td&gt;emails, phones, SSNs, credit cards&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Redact&lt;/strong&gt; — &lt;code&gt;[REDACTED:EMAIL]&lt;/code&gt;, request continues&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prompt injection&lt;/td&gt;
&lt;td&gt;"ignore previous instructions", role hijacks, system-prompt probes, jailbreaks&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Flag&lt;/strong&gt; — allowed, but marked&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Blocklist&lt;/td&gt;
&lt;td&gt;your own patterns&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Block&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Every decision lands in an audit log — timestamp, key, detector, action, and a &lt;em&gt;redacted&lt;/em&gt; snippet. Raw PII and secrets never touch the trail. That's your compliance story: &lt;code&gt;GET /admin/audit&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here's what a blocked secret looks like in practice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;POST /v1/chat/completions
{"messages": [{"role": "user", "content": "my aws key is AKIA..."}]}

→ 400 blocked by security policy: secrets:AWS_KEY
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And every successful response tells you what the layer did:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"gateway"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"security"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"redactions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"pii:EMAIL"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"flags"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[]},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"cost_usd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;0.000004&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"tier"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"small"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"degraded"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Cost intelligence rides along
&lt;/h2&gt;

&lt;p&gt;Security is the product, but the gateway also thinks about money — because the same layer that sees every request is the right place to price it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tiered routing&lt;/strong&gt; — requests are scored for difficulty and sent to the cheapest tier that can handle them&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Graceful budgets&lt;/strong&gt; — blow your budget and requests fall back to the cheapest tier instead of dying with a 429 (hard-stop mode if you prefer)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Per-task attribution&lt;/strong&gt; — pass &lt;code&gt;X-Task-Id&lt;/code&gt; and a whole agentic run's spend is ledgered as one task&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This comes from my earlier work on &lt;a href="https://pypi.org/project/tokenecon/" rel="noopener noreferrer"&gt;tokenecon&lt;/a&gt; and the &lt;a href="https://doi.org/10.5281/zenodo.23195511" rel="noopener noreferrer"&gt;paper behind it&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it, break it
&lt;/h2&gt;

&lt;p&gt;It's early — v0.1.0, MIT licensed, and I'd rather have people poke holes in it now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/karmendra8386/argus" rel="noopener noreferrer"&gt;https://github.com/karmendra8386/argus&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;PyPI: &lt;code&gt;pip install argus-gateway&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the roadmap: streaming, Bedrock/Gemini/Mistral adapters, semantic caching, OpenTelemetry export, and an ML-based injection detector (the detector interface is pluggable — contributions welcome).&lt;/p&gt;

&lt;p&gt;If you've ever wondered what your prompts actually carry out the door — point Argus at your traffic for a day and check the audit log. You might be surprised. I was.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>security</category>
      <category>opensource</category>
      <category>python</category>
    </item>
    <item>
      <title>The Receipt: I Priced Every Token of One AI Agent Task</title>
      <dc:creator>karmendra pandey</dc:creator>
      <pubDate>Tue, 06 Oct 2026 14:16:57 +0000</pubDate>
      <link>https://dev.to/karmendra_pandey_43ac6983/the-receipt-i-priced-every-token-of-one-ai-agent-task-4ibp</link>
      <guid>https://dev.to/karmendra_pandey_43ac6983/the-receipt-i-priced-every-token-of-one-ai-agent-task-4ibp</guid>
      <description>&lt;p&gt;Everyone talks about AI costs in aggregate. Dashboards show monthly spend, per-model totals, team budgets. Nobody shows you a receipt.&lt;/p&gt;

&lt;p&gt;So here's one. A single AI agent task, priced line by line — every token, every tool call, every retry. This is a worked example from production-style workloads I describe in my reference architecture work (full paper: &lt;a href="https://doi.org/10.5281/zenodo.23178788" rel="noopener noreferrer"&gt;https://doi.org/10.5281/zenodo.23178788&lt;/a&gt;). The numbers are representative of a mid-complexity support-triage agent running on AWS Bedrock. Your numbers will differ. The shape of the receipt won't.&lt;/p&gt;

&lt;h2&gt;
  
  
  The task
&lt;/h2&gt;

&lt;p&gt;A customer support triage agent: read an incoming ticket, pull the customer's history, check the knowledge base, decide whether to auto-resolve or escalate, and draft the response. One task, one receipt.&lt;/p&gt;

&lt;h2&gt;
  
  
  The receipt
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;#&lt;/th&gt;
&lt;th&gt;Line item&lt;/th&gt;
&lt;th&gt;Tokens in&lt;/th&gt;
&lt;th&gt;Tokens out&lt;/th&gt;
&lt;th&gt;Unit cost basis&lt;/th&gt;
&lt;th&gt;Cost&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;System prompt (loaded once, cached)&lt;/td&gt;
&lt;td&gt;1,850&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;cached input&lt;/td&gt;
&lt;td&gt;$0.0011&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Ticket text + customer history&lt;/td&gt;
&lt;td&gt;2,300&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;standard input&lt;/td&gt;
&lt;td&gt;$0.0069&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Knowledge base retrieval (3 chunks)&lt;/td&gt;
&lt;td&gt;4,100&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;standard input&lt;/td&gt;
&lt;td&gt;$0.0123&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Reasoning: triage decision&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;420&lt;/td&gt;
&lt;td&gt;standard output&lt;/td&gt;
&lt;td&gt;$0.0050&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Tool call: CRM lookup&lt;/td&gt;
&lt;td&gt;180&lt;/td&gt;
&lt;td&gt;90&lt;/td&gt;
&lt;td&gt;in/out&lt;/td&gt;
&lt;td&gt;$0.0016&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Reasoning: draft response&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;680&lt;/td&gt;
&lt;td&gt;standard output&lt;/td&gt;
&lt;td&gt;$0.0082&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;Retry: first draft failed tone eval, regenerated&lt;/td&gt;
&lt;td&gt;6,200&lt;/td&gt;
&lt;td&gt;710&lt;/td&gt;
&lt;td&gt;in (cached) + out&lt;/td&gt;
&lt;td&gt;$0.0121&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Embedding: ticket for memory store&lt;/td&gt;
&lt;td&gt;340&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;embedding&lt;/td&gt;
&lt;td&gt;$0.0000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;Final response + audit log write&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;350&lt;/td&gt;
&lt;td&gt;standard output&lt;/td&gt;
&lt;td&gt;$0.0042&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Total&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~15,000&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~2,250&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;~$0.051&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Wait — $0.051, not $0.23? The $0.23 figure from my paper is the fully-loaded cost: it includes the amortized cost of the eval harness, the retrieval infrastructure, and the human review queue time for escalations. The raw inference receipt is five cents. The &lt;em&gt;governed&lt;/em&gt; cost is twenty-three cents. Both numbers matter, and most teams track neither.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading the receipt
&lt;/h2&gt;

&lt;p&gt;Three things jump out:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The retry cost more than the original attempt.&lt;/strong&gt; Line 7 cost $0.0121 — nearly as much as lines 4 and 6 combined ($0.0132). Retries are the silent budget killer in agent systems. Every eval gate you add has a cost; every gate you skip has a bigger one. The receipt lets you price the tradeoff instead of guessing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Context is the bulk of input spend.&lt;/strong&gt; Lines 2+3 are 6,400 input tokens — 43% of the total input. That knowledge-base retrieval is doing real work, but it's also the first place to optimize: better chunking, semantic caching of frequent queries, and prompt compression all attack this line directly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. The system prompt is nearly free — because it's cached.&lt;/strong&gt; Line 1 costs a tenth of a cent thanks to prompt caching. Without caching, that 1,850-token system prompt gets re-priced on every call in the chain. If your provider supports caching and you're not using it, you're donating money.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the receipt is the unit of cost governance
&lt;/h2&gt;

&lt;p&gt;You can't govern what you can't itemize. Monthly dashboards tell you &lt;em&gt;that&lt;/em&gt; you spent $40K. The receipt tells you &lt;em&gt;why&lt;/em&gt; — which line items to attack, which eval gates earn their keep, which retries are worth preventing.&lt;/p&gt;

&lt;p&gt;Three practices that fall out of this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Emit a receipt per task.&lt;/strong&gt; Log input/output tokens per span — per agent, per tool call, per retry. If your framework doesn't do this natively, add a callback handler.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Budget at the task level, not the month level.&lt;/strong&gt; A per-task budget with a circuit breaker ("halt if projected cost exceeds $X") catches runaway loops in seconds instead of at invoice time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Price your eval gates.&lt;/strong&gt; Every quality check costs tokens. The receipt tells you whether the gate is cheaper than the failure it prevents.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The next time someone asks what your AI agents cost, don't open the dashboard. Show them a receipt.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Karmendra Pandey is a Practice Architect in AI &amp;amp; ML at TEK Systems, building production agentic AI on AWS. His reference architecture for cost-governed AI agents is at &lt;a href="https://doi.org/10.5281/zenodo.23178788" rel="noopener noreferrer"&gt;https://doi.org/10.5281/zenodo.23178788&lt;/a&gt;, and the companion implementation at &lt;a href="https://github.com/karmendra8386/agentic-ai-aws-reference" rel="noopener noreferrer"&gt;https://github.com/karmendra8386/agentic-ai-aws-reference&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>aws</category>
      <category>costoptimization</category>
    </item>
    <item>
      <title>I Audited 5 Agent Frameworks for Cost Visibility. Here's the Scorecard.</title>
      <dc:creator>karmendra pandey</dc:creator>
      <pubDate>Tue, 06 Oct 2026 14:16:15 +0000</pubDate>
      <link>https://dev.to/karmendra_pandey_43ac6983/i-audited-5-agent-frameworks-for-cost-visibility-heres-the-scorecard-4pe4</link>
      <guid>https://dev.to/karmendra_pandey_43ac6983/i-audited-5-agent-frameworks-for-cost-visibility-heres-the-scorecard-4pe4</guid>
      <description>&lt;p&gt;Every agent framework promises observability. Traces, spans, dashboards. But ask a harder question — &lt;em&gt;how much did that agent run cost, and who do I bill?&lt;/em&gt; — and the answers get thin fast.&lt;/p&gt;

&lt;p&gt;So I audited five of the most-used agent frameworks against one rubric: cost visibility. Not general observability — the specific ability to see, attribute, and control spend. I read the official docs for each (sources linked throughout). No guessing, no marketing pages. Here's the scorecard.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rubric
&lt;/h2&gt;

&lt;p&gt;Four questions, scored 1–5:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Does it track token usage natively, per run / per agent / per tool call?&lt;/li&gt;
&lt;li&gt;Does it convert tokens to dollars?&lt;/li&gt;
&lt;li&gt;Can you attribute spend to an agent, session, or user out of the box?&lt;/li&gt;
&lt;li&gt;Does it support budgets or cost guardrails natively?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The scorecard
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Framework&lt;/th&gt;
&lt;th&gt;Score&lt;/th&gt;
&lt;th&gt;Verdict&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;LangGraph + LangSmith&lt;/td&gt;
&lt;td&gt;5/5&lt;/td&gt;
&lt;td&gt;The gold standard&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Amazon Bedrock AgentCore&lt;/td&gt;
&lt;td&gt;5/5&lt;/td&gt;
&lt;td&gt;Zero-wiring cost visibility&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Strands Agents SDK&lt;/td&gt;
&lt;td&gt;4/5&lt;/td&gt;
&lt;td&gt;Best guardrails, priced in tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CrewAI&lt;/td&gt;
&lt;td&gt;3/5&lt;/td&gt;
&lt;td&gt;Tokens yes, dollars DIY&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AutoGen (v0.4)&lt;/td&gt;
&lt;td&gt;2/5&lt;/td&gt;
&lt;td&gt;Went backwards&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  LangGraph + LangSmith: 5/5
&lt;/h2&gt;

&lt;p&gt;LangSmith does the thing everyone else stops short of: it converts tokens to dollars automatically, using a customizable per-model pricing table (docs: &lt;a href="https://docs.langchain.com/langsmith/cost-tracking" rel="noopener noreferrer"&gt;https://docs.langchain.com/langsmith/cost-tracking&lt;/a&gt;). Custom or non-linear pricing goes through &lt;code&gt;usage_metadata&lt;/code&gt;. The trace tree breaks cost down per node, so you can separate what the supervisor spent from what the specialist agents spent. Metadata-based attribution covers users and sessions, and there are dashboards on top.&lt;/p&gt;

&lt;p&gt;The blind spot: no native budget enforcement. You can &lt;em&gt;see&lt;/em&gt; every dollar with precision — you just can't make the framework &lt;em&gt;stop&lt;/em&gt; spending them. Visibility without teeth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bedrock AgentCore: 5/5
&lt;/h2&gt;

&lt;p&gt;The managed CloudWatch GenAI dashboard shows per-invocation token usage &lt;strong&gt;and cost&lt;/strong&gt; with zero wiring — no callbacks, no exporters, no pricing tables to maintain. Per-user traceability comes through span attributes, and tenant attribution via OpenTelemetry baggage.&lt;/p&gt;

&lt;p&gt;The blind spot: spend control is external. It's CloudWatch alarms plus AWS Budgets — both notify-only. The platform will tell you, beautifully, exactly how much you overspent. It won't pull the plug.&lt;/p&gt;

&lt;h2&gt;
  
  
  Strands Agents SDK: 4/5
&lt;/h2&gt;

&lt;p&gt;Every &lt;code&gt;AgentResult&lt;/code&gt; carries automatic per-invocation token metrics — input, output, total, cache tokens, plus per-tool stats (docs: &lt;a href="https://strandsagents.com/docs/user-guide/sdk/observability-evaluation/metrics/" rel="noopener noreferrer"&gt;https://strandsagents.com/docs/user-guide/sdk/observability-evaluation/metrics/&lt;/a&gt;). And Strands is the &lt;strong&gt;only&lt;/strong&gt; framework in this group with native budget caps: &lt;code&gt;limits={"turns", "output_tokens", "total_tokens"}&lt;/code&gt; halts the agent loop with explicit stop reasons.&lt;/p&gt;

&lt;p&gt;The blind spot: the caps are token-denominated, and there's no dollar conversion. A 10,000-token cap means wildly different dollars on Haiku vs. Opus. It's the only framework with a native kill-switch — it just thinks in the wrong currency.&lt;/p&gt;

&lt;h2&gt;
  
  
  CrewAI: 3/5
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;token_usage&lt;/code&gt; on every &lt;code&gt;kickoff()&lt;/code&gt; result is genuinely zero-setup, and per-task usage rides along on &lt;code&gt;TaskOutput&lt;/code&gt;. The event bus plus OpenTelemetry export gives you the plumbing to build whatever you want (docs: &lt;a href="https://docs.crewai.com/v1.15.12/en/observability/overview" rel="noopener noreferrer"&gt;https://docs.crewai.com/v1.15.12/en/observability/overview&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;The blind spot: the framework stops at tokens. No pricing, no dashboard, no budgets. Dollar cost is a DIY project, and per-agent attribution needs custom event listeners. You get the raw material of cost visibility and none of the product.&lt;/p&gt;

&lt;h2&gt;
  
  
  AutoGen (v0.4): 2/5
&lt;/h2&gt;

&lt;p&gt;Here's the irony: AutoGen &lt;strong&gt;had&lt;/strong&gt; built-in cost logging. Version 0.2 shipped &lt;code&gt;start_logging&lt;/code&gt; / &lt;code&gt;print_usage_summary&lt;/code&gt; with cost computation. Then came the v0.4 rewrite — and cost visibility went backwards. The current telemetry story is native OpenTelemetry with GenAI semantic-convention spans (docs: &lt;a href="https://microsoft.github.io/autogen/stable/user-guide/core-user-guide/framework/telemetry.html):" rel="noopener noreferrer"&gt;https://microsoft.github.io/autogen/stable/user-guide/core-user-guide/framework/telemetry.html):&lt;/a&gt; token data exists as span attributes for &lt;em&gt;your&lt;/em&gt; backend to aggregate. No first-party cost computation, no dashboard, no budgets.&lt;/p&gt;

&lt;p&gt;The blind spot: everything. The most popular multi-agent framework in the ecosystem currently treats cost as somebody else's problem — and it used to be better at this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three patterns
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. The industry stops at tokens.&lt;/strong&gt; Only LangSmith and AgentCore convert to dollars natively. Everyone else hands you token counts and wishes you luck with the pricing page. Tokens are an implementation detail; dollars are the budget. The gap between them is where finance teams lose trust in AI projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Nobody ships a dollar kill-switch.&lt;/strong&gt; Strands has token caps. AutoGen has a token-limited context. Everything else is alarms and custom logic. As of today, no major framework lets you say "halt this agent if it spends more than $2" — in dollars, natively, enforced. That missing primitive is the single biggest gap in agent cost governance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Visibility went backwards on at least one framework.&lt;/strong&gt; AutoGen's regression from v0.2 to v0.4 is a cautionary tale: cost features are the first thing cut in a rewrite because they're nobody's launch-blocking requirement — until the invoice arrives.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to do about it
&lt;/h2&gt;

&lt;p&gt;If you're picking a framework this quarter: LangSmith or AgentCore if you want cost visibility today; Strands if you want guardrails and can live with token-denominated caps. If you're already on CrewAI or AutoGen, budget a sprint for the DIY layer — token export, a pricing table, per-agent attribution, and an external budget alarm — because the framework isn't going to do it for you.&lt;/p&gt;

&lt;p&gt;And framework maintainers: the tokens-to-dollars gap is the most valuable ten lines of code in your roadmap. Ship the pricing table. Ship the dollar cap. Your users' CFOs will thank you.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Methodology: scored against official documentation as of October 2026. Karmendra Pandey is a Practice Architect in AI &amp;amp; ML at TEK Systems, working on cost-governed AI agents on AWS. Reference architecture: &lt;a href="https://doi.org/10.5281/zenodo.23178788" rel="noopener noreferrer"&gt;https://doi.org/10.5281/zenodo.23178788&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>opensource</category>
      <category>costoptimization</category>
    </item>
    <item>
      <title>How to Audit an ML Design Before It Ships</title>
      <dc:creator>karmendra pandey</dc:creator>
      <pubDate>Tue, 06 Oct 2026 05:45:52 +0000</pubDate>
      <link>https://dev.to/karmendra_pandey_43ac6983/how-to-audit-an-ml-design-before-it-ships-1f95</link>
      <guid>https://dev.to/karmendra_pandey_43ac6983/how-to-audit-an-ml-design-before-it-ships-1f95</guid>
      <description>&lt;h1&gt;
  
  
  How to Audit an ML Design Before It Ships
&lt;/h1&gt;

&lt;p&gt;Most ML failures are not model failures. They are &lt;em&gt;design&lt;/em&gt; failures — and they are almost always visible before launch to anyone who knows where to look.&lt;/p&gt;

&lt;p&gt;Training-serving skew nobody checked. An evaluation set that doesn't match production. A feedback loop that will quietly poison the next retraining run. Cost and latency budgets nobody wrote down. I've watched these kill systems that had perfectly good models. After 19+ years of shipping software and reviewing AI research, I now run every ML design through the same five-gate audit before it ships. Here it is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 1: Data — provenance, leakage, drift
&lt;/h2&gt;

&lt;p&gt;Ask three questions. Where did every training example come from, and can you prove it? Could any information from the future — or from the test set — have leaked into training? And what happens when the real world drifts away from your training distribution?&lt;/p&gt;

&lt;p&gt;The classic killer here is eval leakage: the "99% accurate" classifier that fails on its first real day because the eval set was accidentally drawn from training data. It happens more than anyone admits. Demand a written data provenance statement and a leakage check as merge requirements, not nice-to-haves.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 2: Evaluation — does the metric match the mission?
&lt;/h2&gt;

&lt;p&gt;A model can ace its metric and still fail its job. Offline accuracy means nothing if the production decision has different costs for different errors — a fraud model optimized for accuracy will happily approve everything when fraud is rare.&lt;/p&gt;

&lt;p&gt;For every model, write down: what decision does this model actually drive, what does a mistake cost in each direction, and does our eval set look like production traffic? If the answers are vague, the design isn't ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 3: Operations — latency, cost, fallback
&lt;/h2&gt;

&lt;p&gt;Nobody writes down the latency budget until the first user complaint. Nobody prices the prediction until the first cloud bill. For each model, record: p95 latency budget, cost per 1,000 predictions at expected volume, and what happens when the model is down or too slow. "The page breaks" is not a fallback strategy — cache the last good prediction, degrade to a simpler model, or fail open explicitly and loudly.&lt;/p&gt;

&lt;p&gt;For agentic systems this gate matters 10x more: every unnecessary tool call burns tokens &lt;em&gt;and&lt;/em&gt; inflates every downstream context window. Cost discipline starts with call discipline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 4: Security — adversarial inputs and access control
&lt;/h2&gt;

&lt;p&gt;Who can feed inputs to this model, and what can they make it do? Cover the basics: input validation, rate limiting, access controls on the model endpoint and its training data. For LLM-backed systems, add prompt-injection review — treat every tool the agent can call as a privilege, and scope it like one. I model agents as IAM principals: unique identity, least-privilege roles, session-scoped credentials.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gate 5: Accountability — who owns the decision?
&lt;/h2&gt;

&lt;p&gt;When the model is wrong — and it will be — who is accountable, and what is the remediation path? Every production ML system needs a named owner, a rollback plan, and a written policy for the failure modes you &lt;em&gt;know&lt;/em&gt; exist. "The model decided" is not an accountability structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one-page audit
&lt;/h2&gt;

&lt;p&gt;Turn these gates into a single page your team fills out at design review:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Data:&lt;/strong&gt; provenance documented? leakage check passed? drift monitors planned?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evaluation:&lt;/strong&gt; metric matches the mission? eval set production-representative?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operations:&lt;/strong&gt; latency budget, cost per prediction, fallback behavior defined?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security:&lt;/strong&gt; inputs validated? access scoped? agent tools least-privilege?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accountability:&lt;/strong&gt; named owner? rollback plan? known failure modes written down?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Any blank answer blocks the ship. It takes an hour, and it catches the failures that postmortems always describe as "obvious in hindsight."&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Karmendra Pandey is a Practice Architect in AI &amp;amp; ML at TEKsystems. He builds production agentic AI systems on AWS and peer-reviews AI research on PREreview.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>ai</category>
      <category>mlops</category>
      <category>datascience</category>
    </item>
    <item>
      <title>I Found a Cost Blind Spot in an Open-Source Agent Framework</title>
      <dc:creator>karmendra pandey</dc:creator>
      <pubDate>Tue, 06 Oct 2026 05:20:49 +0000</pubDate>
      <link>https://dev.to/karmendra_pandey_43ac6983/i-found-a-cost-blind-spot-in-an-open-source-agent-framework-34b9</link>
      <guid>https://dev.to/karmendra_pandey_43ac6983/i-found-a-cost-blind-spot-in-an-open-source-agent-framework-34b9</guid>
      <description>&lt;h1&gt;
  
  
  I Found a Cost Blind Spot in an Open-Source Agent Framework
&lt;/h1&gt;

&lt;p&gt;I was building cost attribution for AI agents on AWS when I ran into a gap in the open-source Strands Agents SDK: the framework knew how to talk to Amazon Bedrock models, but it didn't know which &lt;em&gt;family&lt;/em&gt; some of them belonged to. That sounds like trivia. It turned out to be a cost-governance blind spot — and fixing it taught me something about how open-source contributions actually happen.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;The Strands harness SDK keeps a registry of model families for Bedrock — it uses the family to make decisions about capabilities and pricing behavior. But several Bedrock model families were missing from the registry. When your agent ran on one of those models, the framework couldn't classify it. Depending on the code path, that meant falling back to defaults that didn't match the model's real cost or capability profile.&lt;/p&gt;

&lt;p&gt;In a cost-governed setup, "unknown model family" is not a minor metadata gap. If you can't identify the model, you can't attribute its cost correctly, you can't route to or away from it intelligently, and your burn-rate dashboard has a hole in it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding it
&lt;/h2&gt;

&lt;p&gt;I found it the unglamorous way: reading the source. I was tracing how the SDK resolved model metadata for a Bedrock deployment and noticed the family lookup silently returning nothing for models I knew existed. No error, no warning — just a quiet gap. That's the worst kind of bug in cost infrastructure: it doesn't fail, it just misleads.&lt;/p&gt;

&lt;p&gt;I filed it as &lt;a href="https://github.com/strands-agents/harness-sdk/issues/4852" rel="noopener noreferrer"&gt;issue #4852&lt;/a&gt; in the strands-agents/harness-sdk repository, documenting exactly which families were missing and what the downstream effects were.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;The fix itself was small — extending the family registry to cover the missing Bedrock families, with tests proving each new mapping resolved correctly. I added four new tests, ran the full suite (152 passed), and confirmed the 13 pre-existing failures also failed on clean main, so they weren't mine.&lt;/p&gt;

&lt;p&gt;Small fix, but the verification mattered more than the code. In cost infrastructure, a wrong mapping is worse than a missing one — it makes your dashboards lie with confidence.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;p&gt;Three things worth sharing:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Read the source before the docs.&lt;/strong&gt; The docs described the registry as complete. The source said otherwise. For cost-critical paths, the source is the only documentation you can trust.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File the issue before the PR.&lt;/strong&gt; Writing up #4852 first forced me to articulate the &lt;em&gt;impact&lt;/em&gt;, not just the bug. That made the fix obviously correct to reviewers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test the mapping, not just the code.&lt;/strong&gt; The interesting assertions weren't "does it run" but "does this model resolve to the right family" — the semantic correctness that cost attribution depends on.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why this matters beyond one PR
&lt;/h2&gt;

&lt;p&gt;Every team running agents in production is building cost governance on top of frameworks like this one. The frameworks are young, the model landscape changes monthly, and gaps like this one are everywhere — quiet, unremarkable, and expensive in aggregate.&lt;/p&gt;

&lt;p&gt;If you're running agents on Bedrock, check your model metadata paths. The bug you find might be as boring as a missing registry entry. Fix it anyway. Your burn-rate dashboard will thank you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P.S. — pricing the whole task, not just the mapping.&lt;/strong&gt; Fixing the metadata was one half of the cost story. The other half is knowing what a full agent run costs before the bill arrives. I built &lt;a href="https://pypi.org/project/tokenecon/" rel="noopener noreferrer"&gt;tokenecon&lt;/a&gt; for that — &lt;code&gt;pip install tokenecon&lt;/code&gt;, point its &lt;code&gt;CostTracker&lt;/code&gt; at a Strands agent, and every run prints a per-step cost receipt. It's the companion to the paper &lt;a href="https://doi.org/10.5281/zenodo.23195511" rel="noopener noreferrer"&gt;&lt;em&gt;Token-Economics for Agentic AI&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The fix is &lt;a href="https://github.com/strands-agents/harness-sdk/pull/4853" rel="noopener noreferrer"&gt;PR #4853&lt;/a&gt; in strands-agents/harness-sdk. Karmendra Pandey is a Practice Architect in AI &amp;amp; ML at TEKsystems.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>ai</category>
      <category>aws</category>
      <category>programming</category>
    </item>
    <item>
      <title>Your AI Agent Has a Burn Rate: Governing the Cost of Production AI Agents on AWS</title>
      <dc:creator>karmendra pandey</dc:creator>
      <pubDate>Tue, 06 Oct 2026 05:19:55 +0000</pubDate>
      <link>https://dev.to/karmendra_pandey_43ac6983/your-ai-agent-has-a-burn-rate-governing-the-cost-of-production-ai-agents-on-aws-1jil</link>
      <guid>https://dev.to/karmendra_pandey_43ac6983/your-ai-agent-has-a-burn-rate-governing-the-cost-of-production-ai-agents-on-aws-1jil</guid>
      <description>&lt;h1&gt;
  
  
  Your AI Agent Has a Burn Rate: Governing the Cost of Production AI Agents on AWS
&lt;/h1&gt;

&lt;p&gt;Every AI pilot I have reviewed in the last two years had the same surprise waiting in production: the invoice. A demo that cost $40 to run suddenly costs $4,000 a month at real traffic. Nobody planned for it because nobody was measuring it. Your AI agent has a burn rate — cost per task, per user, per day — and if you are not governing it, you are flying blind.&lt;/p&gt;

&lt;p&gt;This is the practitioner's guide to cost-governed agents on AWS: what to measure, where the money actually goes, and the architecture patterns that keep the burn rate under control.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the money goes
&lt;/h2&gt;

&lt;p&gt;For a typical agent built on Amazon Bedrock, the cost stack looks like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Model inference&lt;/strong&gt; — the big one. Every token in and out is metered. Long system prompts, verbose reasoning traces, and multi-step agent loops multiply this fast.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retrieval&lt;/strong&gt; — OpenSearch or Kendra queries per agent step. Cheap per call, expensive at scale.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tool calls&lt;/strong&gt; — Lambda invocations, API calls, data transfers. Each agent step can trigger several.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Retries and loops&lt;/strong&gt; — the silent killer. An agent that retries a failing step five times just quintupled that task's cost.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Most teams only see line 1 on the bill. The real burn rate is the sum of all four, attributed per task.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern 1: Attribute cost per task
&lt;/h2&gt;

&lt;p&gt;You cannot govern what you cannot attribute. Every agent execution should log: input tokens, output tokens, model used, tool calls made, and wall-clock time — tagged with a task ID and a user or tenant ID. On AWS, this means structured logging from your Bedrock invocations into CloudWatch, with a pipeline that rolls it up per task.&lt;/p&gt;

&lt;p&gt;The moment you can say "this customer support task cost $0.42 and this one cost $3.80," you can start asking why — and that question is where the savings live.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern 2: Route, don't default
&lt;/h2&gt;

&lt;p&gt;Not every task needs the flagship model. A classification step, a format check, a simple extraction — these run fine on smaller, cheaper models at a tenth of the cost. The expensive model should be reserved for the steps that actually need judgment.&lt;/p&gt;

&lt;p&gt;This is the routing pattern: a lightweight decision at each step picks the cheapest model capable of handling it. In practice, teams that add routing cut inference spend 40–70% with no measurable quality drop — because most agent steps were never hard enough to justify the big model in the first place.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern 3: Cap the loop
&lt;/h2&gt;

&lt;p&gt;Agents loop. Sometimes they loop forever. Every production agent needs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A max-iteration cap&lt;/strong&gt; per task (if it hasn't converged in N steps, it won't).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A cost ceiling per task&lt;/strong&gt; — abort or escalate to a human when the spend crosses the line.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Idempotent tool calls&lt;/strong&gt; — so a retry doesn't double-charge a payment API or re-send a customer email.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are not optimizations. They are the guardrails that keep one bad task from burning a day's budget.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pattern 4: Cache the predictable
&lt;/h2&gt;

&lt;p&gt;A surprising share of agent work is repetitive: the same policy lookup, the same product description, the same classification of the same ticket type. Cache retrieval results and deterministic step outputs aggressively. Bedrock's prompt caching and a simple Redis layer in front of your retrieval calls compound into real savings.&lt;/p&gt;

&lt;h2&gt;
  
  
  The burn-rate dashboard
&lt;/h2&gt;

&lt;p&gt;Put it together and you get one view that matters: cost per task, trended over time, broken down by model, step type, and tenant. When a new model version ships or a prompt changes, the dashboard tells you within hours whether the burn rate moved — before the invoice does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start this week
&lt;/h2&gt;

&lt;p&gt;You don't need a platform rebuild. Pick one agent, add per-task cost logging, and look at the numbers for a week. The waste will introduce itself. Then route one step to a smaller model, cap one loop, and cache one retrieval call. Measure again.&lt;/p&gt;

&lt;p&gt;Cost governance isn't about spending less on AI. It's about knowing what each dollar bought — and making sure the expensive dollars went to the steps that deserved them.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Karmendra Pandey is a Practice Architect in AI &amp;amp; ML at TEKsystems, where he designs production AI agent systems on AWS.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>aws</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
