<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[bigai]]></title><description><![CDATA[bigai]]></description><link>https://bigai.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Thu, 12 Nov 2026 07:21:44 GMT</lastBuildDate><atom:link href="https://bigai.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Does It Save Tokens? TokenEconomizer on DeepSeek Harness]]></title><description><![CDATA[I ported TokenEconomizer to DeepSeek Harness and ran 12 A/B sessions. Total tokens: 209,263 with the plugin, 208,239 without, a 0.5% gap.]]></description><link>https://bigai.hashnode.dev/does-it-save-tokens-tokeneconomizer-on-deepseek-harness</link><guid isPermaLink="true">https://bigai.hashnode.dev/does-it-save-tokens-tokeneconomizer-on-deepseek-harness</guid><category><![CDATA[AI]]></category><category><![CDATA[Deepseek]]></category><category><![CDATA[tokens]]></category><dc:creator><![CDATA[ming]]></dc:creator><pubDate>Tue, 03 Nov 2026 13:37:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6ae7ec969270da540362977f/4630e76b-9027-4f39-9084-bca29c0130d1.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>This is the second version of this test. The first one found a 0.5% difference and could not tell it apart from noise; this one finds 6.63% fewer prompt tokens per step, and the confidence interval stays below zero. Most of the difference comes from how the experiment was built, so the redesign comes first and the number second.</em></p>
<p>Microsoft's TokenEconomizer reports 18.4 to 30.9% lower mean cost on SWE-Bench, cheaper in all 30 repository × model cells, and Pass@1 up in 4 of 5 combinations. I ported the idea to DeepSeek Harness, ran a first A/B test, and got nothing I could defend. That result stays in the record: twelve sessions, plugin on versus off, +0.5% at the group level, the two short tasks pointing in opposite directions, all of it inside a pre-registered ±15% noise band.</p>
<p>The honest reading was that my experiment could not see the effect even if it was there. So I rebuilt the measurement, pre-registered a verdict rule, and ran it again: 24 matched pairs, 48 sessions, 139 paired steps, one frozen starting state. This time the plugin saves tokens, and I can say how much.</p>
<h2>What was wrong with the first test</h2>
<p>Three things went wrong, and only one was sample size.</p>
<p>One-shot read-only sessions. Every first-test run was a single-turn subagent session that read files and stopped. Tool pruning never fired because the agent never got far enough, so the two most interesting mechanisms had nothing to act on. I was measuring the thinnest mechanism, a per-session micro-skills injection, in the setting where it matters least.</p>
<p>Cache noise at n = 2. The primary metric was <code>inputTokens + outputTokens</code>, and uncached input mostly measures cache behavior: B1 posted 3.3× B2's uncached input on the same task, while total prompt volume moved 6%. With two repeats per cell, that noise was the result.</p>
<p>No verdict rule before the data. After the fact, everyone can find a reading. I wanted the decision made before the runs: what counts as "saves", what counts as "doesn't", and what counts as "inconclusive".</p>
<h2>What I changed</h2>
<p>Step 1: pre-heat, then freeze. Tool exposure is driven by usage history, so every session starts from a warm state rather than an empty one. I ran six setup sessions to populate the plugin's state, then waited 62 minutes (3,728.8 seconds of measured idle time) so the tool-pruning pass and the fact distillation had completed, then snapshotted the state. Every A and B session after that started from that snapshot. The plugin state was never written to during the experiment.</p>
<p>Step 2: 24 matched pairs, alternating order. Six tasks, four repeats each, two arms. The arm order alternates AB, BA, AB, BA within each task. Same model (<code>opencode-go / deepseek-v4.1-flash</code>, <code>reasoningEffort=max</code>), same repo, same task prompt, same headless tool surface. A is the plugin on; B is the plugin with <code>enabled: false</code>, everything else identical.</p>
<p>Step 3: the verdict rule, written down first. The test counts as a save only if both hold: the 95% bootstrap CI upper bound on the per-step prompt-token delta is below zero, and the absolute saving is at least 300 tokens per step. This is what stops a 0.3% result from being reported as a win.</p>
<p>I also checked that the mechanism actually fired. A token difference with no mechanism behind it is a bug. The frozen A-arm header carried 15 tools and 16,503 bytes, with 8 of the 23 tools denied by pruning; B carried 23 tools and 19,997 bytes. A also injected 214 characters of micro-skills context into every session from the second step on. No injection reached B.</p>
<h2>What the 24 pairs said</h2>
<p>The primary metric is prompt tokens per step: <code>inputTokens + cacheReadTokens</code>, counted per model call, so a long session and a short session contribute the same unit. Across 139 paired steps:</p>
<table>
<thead>
<tr>
<th></th>
<th>A · plugin on</th>
<th>B · plugin off</th>
</tr>
</thead>
<tbody><tr>
<td>Mean prompt tokens per step</td>
<td>12,010.8</td>
<td>12,864.2</td>
</tr>
<tr>
<td>Difference</td>
<td>−853.4 tokens/step</td>
<td>95% CI [−1,066.2, −627.7]</td>
</tr>
<tr>
<td>Relative</td>
<td>−6.63%</td>
<td>95% CI [−8.15%, −4.92%]</td>
</tr>
</tbody></table>
<p>A spends 93.37% of what B spends per step. The median paired difference is −804 tokens per step, and the mean of the 24 pair-level means is −842.5, so the result isn't one or two dramatic pairs dragging the mean.</p>
<p>Two sub-results:</p>
<ul>
<li>Step 1: −904 tokens, or −8.05%. The first model call of a session has no conversation context yet, so this isolates the tool-schema difference almost perfectly. It is also deterministic: every pair shows the same −904, which is why the interval collapses.</li>
<li>Step 2 onward: −842.9 tokens, or −6.38% (95% CI [−8.17%, −4.37%]). On later steps conversation content is present, and the relative advantage shrinks slightly but stays below zero.</li>
</ul>
<p>Every one of the six tasks moved the same way:</p>
<table>
<thead>
<tr>
<th>Task</th>
<th>Pairs</th>
<th>Δ tokens/step</th>
<th>Relative</th>
</tr>
</thead>
<tbody><tr>
<td><code>stats-mean-null</code></td>
<td>4</td>
<td>−755.0</td>
<td>−6.46%</td>
</tr>
<tr>
<td><code>stats-median</code></td>
<td>4</td>
<td>−735.0</td>
<td>−5.45%</td>
</tr>
<tr>
<td><code>format-currency</code></td>
<td>4</td>
<td>−771.5</td>
<td>−6.54%</td>
</tr>
<tr>
<td><code>utils-clamp</code></td>
<td>4</td>
<td>−624.1</td>
<td>−4.68%</td>
</tr>
<tr>
<td><code>rename-computetotal</code></td>
<td>4</td>
<td>−923.0</td>
<td>−7.02%</td>
</tr>
<tr>
<td><code>add-median-test</code></td>
<td>4</td>
<td>−1,246.3</td>
<td>−9.34%</td>
</tr>
</tbody></table>
<p>The weakest task (−4.68%) and the strongest (−9.34%) differ by roughly the size of the effect itself. That is a warning about per-task claims: six tasks, four repeats, and one repo cannot support "the plugin saves 9% on refactors."</p>
<p>Total tokens per session tell a noisier story: 2,053,523 in B against 1,902,222 in A, a −7.37% reduction, but the paired 95% CI is [−15,761.5, +3,215.3] and crosses zero. Total tokens include output length, which the plugin does not control, and cache behavior, which varies with conversation shape. That is why the per-step prompt metric was pre-registered as primary.</p>
<p>Quality held: 48 of 48 sessions passed verification, 24 of 24 pairs were usable, and no session was excluded. Output tokens were essentially identical, A 39,827 in total against B 40,315, so nothing here is paid for by writing less.</p>
<h2>What this does not prove</h2>
<ul>
<li>One model, one repository, six short tasks, headless. The headless tool surface is 23 tools in B. A desktop install loads 59, so the absolute bytes removed per request would be larger, but I did not run that configuration and I am not going to multiply numbers I did not measure.</li>
<li>Two mechanisms, one switch. The A-arm advantage combines tool-schema pruning, fixed per request, and micro-skills injection, 214 characters once per session. This experiment treats "plugin on/off" as one unit and does not separate the two.</li>
<li>A pooled ratio estimator with a cluster bootstrap. The headline −6.63% is ΣΔ / ΣB pooled across 139 steps, with a 95% CI from 10,000 bootstrap resamples clustered by the 24 pairs. Per-step deltas are correlated within a session, so the cluster is the pair rather than the step.</li>
<li>Short sessions. The whole experiment is 139 model calls. It says nothing about multi-hour sessions, where per-request schema savings compound while context growth dominates.</li>
</ul>
<h2>The film, the GIFs, the code</h2>
<p>I turned this second round into a 90-second film with HyperFrames, HTML and CSS animated to a timeline, on-screen text only, no voiceover, one music bed. It opens with the number, then covers the failed first test, the redesign, and the result.</p>
<p><a href="https://youtu.be/F82yTG_Vpaw">https://youtu.be/F82yTG_Vpaw</a></p>
<p>Two clips from the film, made with <a href="https://gif-master.com/en/tools/video-to-gif">gif-master's video-to-GIF converter</a>: the three-step design and the result panel.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6ae7ec969270da540362977f/770df6e1-b186-41fc-a4c0-76b4dbc4a213.gif" alt="The three-step redesign: pre-heat, matched pairs, verdict rule" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6ae7ec969270da540362977f/b41195bf-6016-459d-80e4-8969e0495d6b.gif" alt="The result: −6.63% per step, with the confidence interval and the per-task range" style="display:block;margin:0 auto" />

<p>The plugin is public: <a href="https://github.com/Mng12345/dsh-tokeneconomizer">github.com/Mng12345/dsh-tokeneconomizer</a>. It is Apache-2.0, the README documents the DSH hook mapping and configuration, and <code>lib/</code> is committed so you can install it without a build step. The benchmark, raw session logs and preregistration are in a private repository; the design, the verdict rule and every number above come from it.</p>
<h2>Last thing</h2>
<p>The first post ended with "the cost of just being an agent dominates anything a thin layer can shave off." That was too strong, and it described my measurement more than the plugin. With a warm frozen state, matched pairs and a rule written before the data, the thin layer is visible: 853 tokens per step, 6.63%, with the interval and the mechanism both behind it.</p>
<p>The number is small. It is also about the size you would expect from deleting eight tool schemas from every request.</p>
]]></content:encoded></item></channel></rss>