<?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: Vaibhav Krishali</title>
    <description>The latest articles on DEV Community by Vaibhav Krishali (@getawaykr).</description>
    <link>https://dev.to/getawaykr</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%2F4241239%2Fd27fd5cc-4ae7-42dd-96a8-923101d76e2d.png</url>
      <title>DEV Community: Vaibhav Krishali</title>
      <link>https://dev.to/getawaykr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/getawaykr"/>
    <language>en</language>
    <item>
      <title>Prompt caching saved 91% on 7,407 coding-agent calls, and real logs found two bugs in my cost tool</title>
      <dc:creator>Vaibhav Krishali</dc:creator>
      <pubDate>Thu, 12 Nov 2026 15:09:29 +0000</pubDate>
      <link>https://dev.to/getawaykr/prompt-caching-saved-91-on-7407-coding-agent-calls-and-real-logs-found-two-bugs-in-my-cost-tool-3h20</link>
      <guid>https://dev.to/getawaykr/prompt-caching-saved-91-on-7407-coding-agent-calls-and-real-logs-found-two-bugs-in-my-cost-tool-3h20</guid>
      <description>&lt;p&gt;I built a small open-source CLI, &lt;a href="https://github.com/krishalivaibhav/llm-cost-audit" rel="noopener noreferrer"&gt;llm-cost-audit&lt;/a&gt;, that reads LLM call logs and ranks where money could be saved. Synthetic test data said it worked. So I pointed it at 22 days of my own Claude Code sessions to see what real data would say.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short version:&lt;/strong&gt; at list API prices, the 7,407 calls come to &lt;strong&gt;$566&lt;/strong&gt;. Without prompt caching, the same calls would have cost &lt;strong&gt;$6,301&lt;/strong&gt;. The run also caught two bugs in the tool that the synthetic tests never hit.&lt;/p&gt;

&lt;p&gt;(I'm on a subscription, so these are API-price figures, not money I paid. The tool reads only token counts, model names and timestamps, never prompt text.)&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Caching is doing almost all the work
&lt;/h2&gt;

&lt;p&gt;A coding agent re-sends its whole conversation on every turn. The median call read 191,278 input tokens to write 358 output tokens.&lt;/p&gt;

&lt;p&gt;98.3% of those input tokens (1.69 billion) came from the prompt cache, billed at 5% of the normal input price on the models I mostly used. Priced at the full input rate, the same 22 days come to $6,301. Caching cut the bill by 91%.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Where the remaining money goes
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Token type&lt;/th&gt;
&lt;th&gt;Cost&lt;/th&gt;
&lt;th&gt;Share of spend&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cache reads&lt;/td&gt;
&lt;td&gt;$303.82&lt;/td&gt;
&lt;td&gt;54%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cache writes&lt;/td&gt;
&lt;td&gt;$190.53&lt;/td&gt;
&lt;td&gt;34%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Output&lt;/td&gt;
&lt;td&gt;$71.43&lt;/td&gt;
&lt;td&gt;13%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Full-rate input&lt;/td&gt;
&lt;td&gt;$0.06&lt;/td&gt;
&lt;td&gt;0%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Cache writes are 1.7% of input tokens but 34% of spend. 92% of them are 1-hour writes, which cost 2x the input price, against 1.25x for the default 5-minute writes. Whether 5-minute writes would be cheaper here depends on how often calls are more than five minutes apart; I have not measured that yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Bug one: the tool undercounted spend by 12%
&lt;/h2&gt;

&lt;p&gt;The tool priced every cache write at the 5-minute rate. On this log it reported $497.59 instead of $565.85. Any team using 1-hour caching would have got the same undercount.&lt;/p&gt;

&lt;p&gt;The fix reads the 1-hour count Anthropic reports in each response (&lt;code&gt;usage.cache_creation.ephemeral_1h_input_tokens&lt;/code&gt;) and prices it separately. If a model has no 1-hour price, the report now says so instead of quietly undercounting.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Bug two: a placeholder guess outranked a measured finding
&lt;/h2&gt;

&lt;p&gt;Six of the seven findings were "extreme input:output ratio", each with a saving based on a fixed assumption that 25% of the input could be cut. They ranked above the one finding computed from the log.&lt;/p&gt;

&lt;p&gt;For an agent, a huge input and a short answer is normal. The input is the conversation history, and 95 to 98% of it was already cached. The tool now reports this pattern as "long reused context", where the lever is compacting history, not trimming a prompt. Any finding whose saving is a placeholder is marked as illustrative and ranks after every measured one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would check first on a team's agent
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Is caching on, and is it hitting? Here it was worth 91%.&lt;/li&gt;
&lt;li&gt;Which cache lifetime are you paying for? The write price differs by 60% between the two.&lt;/li&gt;
&lt;li&gt;Once caching works, cost grows with context length times the number of turns. Compaction and shorter sessions are the next lever.&lt;/li&gt;
&lt;li&gt;Run any cost tool, including mine, on your real logs before trusting its numbers.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One user, one product, 22 days. Agent cost patterns differ from chat or batch workloads.&lt;/li&gt;
&lt;li&gt;Dollar figures use list prices checked on 11 November 2026, standard tier, no batch or regional pricing.&lt;/li&gt;
&lt;li&gt;Calls were deduplicated by message ID from local transcript files; calls missing from those files are not counted.&lt;/li&gt;
&lt;li&gt;Shares are rounded, so they do not sum to exactly 100%.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;If you're running an LLM product and want the same breakdown on your own logs, the tool is free and open source. I also do this as a paid audit: &lt;a href="https://www.fiverr.com/vaibhavkrishali/audit-your-llm-api-costs-and-show-exactly-where-your-ai-bill-goes" rel="noopener noreferrer"&gt;audit on Fiverr&lt;/a&gt;, or message me.&lt;/p&gt;

</description>
      <category>llm</category>
      <category>ai</category>
      <category>claude</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
