<?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: cos white</title>
    <description>The latest articles on DEV Community by cos white (@cos_white_94c2fac993b29aa).</description>
    <link>https://dev.to/cos_white_94c2fac993b29aa</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%2F4149229%2F85caac42-82db-4775-b3a4-3122f28ae710.jpg</url>
      <title>DEV Community: cos white</title>
      <link>https://dev.to/cos_white_94c2fac993b29aa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cos_white_94c2fac993b29aa"/>
    <language>en</language>
    <item>
      <title>Surgical Subgraphs: How We Cut Coding-Agent Token Costs by 95%</title>
      <dc:creator>cos white</dc:creator>
      <pubDate>Tue, 29 Sep 2026 09:45:59 +0000</pubDate>
      <link>https://dev.to/cos_white_94c2fac993b29aa/surgical-subgraphs-how-we-cut-coding-agent-token-costs-by-95-fk7</link>
      <guid>https://dev.to/cos_white_94c2fac993b29aa/surgical-subgraphs-how-we-cut-coding-agent-token-costs-by-95-fk7</guid>
      <description>&lt;p&gt;Every coding agent has the same expensive habit: when it needs context, it grabs too much of it.&lt;br&gt;
A full-file dump here, a 50-chunk RAG retrieval there — and suddenly a simple "trace this API call"&lt;br&gt;
task burns 12,000+ tokens before the model writes a single line of code. At Claude 3.5 Sonnet pricing&lt;br&gt;
($3.00 / 1M input tokens, Sept 2026), that's $38.09 per 1,000 tasks. For a team running agents all day,&lt;br&gt;
the context bill becomes the real bill.&lt;/p&gt;

&lt;p&gt;We built LKIO (open-source, Apache 2.0) to fix exactly this: a local repository-intelligence engine&lt;br&gt;
that hands agents the &lt;em&gt;minimal sufficient subgraph&lt;/em&gt; instead of a pile of text.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the obvious fixes fail
&lt;/h2&gt;

&lt;p&gt;We benchmarked three approaches on a real 4,899-file business codebase&lt;br&gt;
(Vue 3 frontend + Spring Boot microservices + an enterprise dashboard — not a toy repo):&lt;/p&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;Naive full-file dump&lt;/th&gt;
&lt;th&gt;Chunk RAG (top-k=10)&lt;/th&gt;
&lt;th&gt;LKIO surgical subgraph&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Avg task tokens&lt;/td&gt;
&lt;td&gt;12,698&lt;/td&gt;
&lt;td&gt;4,266&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;545&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;P95 tokens&lt;/td&gt;
&lt;td&gt;24,012&lt;/td&gt;
&lt;td&gt;5,000&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;590&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost / 1k tasks&lt;/td&gt;
&lt;td&gt;$38.09&lt;/td&gt;
&lt;td&gt;$12.80&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$1.64&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cross-stack link recall (n=12)&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;0/12&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;12/12&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hop precision, zero spurious hops (72 hops)&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;72/72&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Chunk RAG looks reasonable until you ask a question that requires a &lt;em&gt;join&lt;/em&gt;:&lt;br&gt;
"trace this Vue form submission through the API client, the REST route, the Spring controller,&lt;br&gt;
the service, the DTO, down to the DB table." Vector search doesn't do joins — it scored &lt;strong&gt;0/12&lt;/strong&gt;&lt;br&gt;
on our 12 end-to-end cross-stack links (Wilson 95% CI: [75.8%, 100.0%]).&lt;br&gt;
LKIO got 12/12 with zero spurious hops, because it doesn't retrieve text. It queries a graph.&lt;/p&gt;

&lt;h2&gt;
  
  
  The core idea: the repo is a database, not a document pile
&lt;/h2&gt;

&lt;p&gt;LKIO continuously parses your codebase with Tree-sitter into fine-grained symbols&lt;br&gt;
(classes, methods, interfaces, Vue SFC blocks) and the relations between them&lt;br&gt;
(calls, imports, DTO field lineage, REST route mappings). That lives in a&lt;br&gt;
copy-on-write in-memory snapshot — readers never block writers, so an agent can query&lt;br&gt;
mid-index with zero stalls. A sliding-window retention policy (last 50 snapshots)&lt;br&gt;
keeps memory bounded: +11.62MB over 1,000 update cycles, no slow leak.&lt;/p&gt;

&lt;p&gt;When an agent asks a question, LKIO doesn't return chunks. It runs a bounded,&lt;br&gt;
cycle-safe BFS from the anchor symbols and returns the smallest subgraph that answers&lt;br&gt;
the question — typically a few hundred tokens. Signal-to-noise ratio goes from ~3%&lt;br&gt;
to ~27%.&lt;/p&gt;

&lt;p&gt;It plugs into any agent via MCP (9 read-only tools, stdio transport):&lt;br&gt;
&lt;code&gt;repo_overview&lt;/code&gt;, &lt;code&gt;list_entities&lt;/code&gt;, &lt;code&gt;search_knowledge&lt;/code&gt;, &lt;code&gt;analyze_impact&lt;/code&gt;,&lt;br&gt;
&lt;code&gt;evaluate_decision&lt;/code&gt;, &lt;code&gt;get_timeline&lt;/code&gt;, and more. Read-only by design —&lt;br&gt;
the MCP layer physically cannot mutate your code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Trust, not just tokens
&lt;/h2&gt;

&lt;p&gt;Two things matter more than the token math for production use:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calibrated confidence.&lt;/strong&gt; On 120 real decision samples, temperature scaling cut&lt;br&gt;
expected calibration error from 0.1850 to 0.0469 (−74.6%, Brier 0.0583).&lt;br&gt;
When LKIO says 0.90 confidence, empirical accuracy is ~91%.&lt;br&gt;
Confidence you can actually use as a probability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Governance that doesn't slow you down.&lt;/strong&gt; The rule is simple: &lt;em&gt;confidence ≠ permission.&lt;/em&gt;&lt;br&gt;
Even at 0.999 confidence, changes to payment cores or auth middleware require human sign-off.&lt;br&gt;
We adversarially tested 8 attack scenarios (regression smuggling, NaN confidences,&lt;br&gt;
empty evidence chains…) — 8/8 blocked. Then we tested the thing teams actually fear:&lt;br&gt;
32 everyday benign changes (renames, extract-function, comment edits, CSS tweaks, i18n fixes) —&lt;br&gt;
32/32 passed, zero false blocks (false-block rate bounded ≤10.7% at 95% confidence).&lt;br&gt;
A gate developers hate is a gate developers disable.&lt;/p&gt;

&lt;h2&gt;
  
  
  It runs on a laptop
&lt;/h2&gt;

&lt;p&gt;Local-first was a design goal, not an afterthought (measured on Intel Core Ultra 9 275HX,&lt;br&gt;
32GB DDR5, Windows 11, Python 3.12.10):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cold start: 1,000 files in &lt;strong&gt;10.61s&lt;/strong&gt; (94.3 files/s, 128.9MB peak RSS)&lt;/li&gt;
&lt;li&gt;Incremental: file save → queryable in &lt;strong&gt;56.4ms&lt;/strong&gt; (incl. 50ms fs-debounce)&lt;/li&gt;
&lt;li&gt;Query latency: symbol lookup ~2μs, depth-2 impact analysis P50 &lt;strong&gt;0.121ms&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Embedding: all-MiniLM-L6-v2 (384-dim, ~90MB) — no GPU required&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Honest limitations
&lt;/h2&gt;

&lt;p&gt;This is a young project (started September 2026, small team).&lt;br&gt;
Our benchmarks are self-reported on our own codebase — the full methodology,&lt;br&gt;
Wilson confidence intervals, and machine-readable results are in&lt;br&gt;
&lt;code&gt;docs/benchmarks/production_acceptance_rigorous_report.md&lt;/code&gt;, and we'd love&lt;br&gt;
independent reproduction.&lt;/p&gt;

&lt;h3&gt;
  
  
  The last mile: dogfooding
&lt;/h3&gt;

&lt;p&gt;All figures above come from rigorous synthetic benchmarks on a real codebase.&lt;br&gt;
But between "admitted to production" and "trusted" there is always one last mile:&lt;br&gt;
a real dev team committing at high frequency for a month.&lt;/p&gt;

&lt;p&gt;We hold the invariant &lt;code&gt;Implementation Complete ≠ Benchmark Validated ≠ Production Gate Passed&lt;/code&gt;,&lt;br&gt;
and we will not dress benchmark scores up as production proof. We are currently running&lt;br&gt;
a 2-week dogfooding program with 1–2 engineers, tracking daily false-block experience&lt;br&gt;
and real agent token spend. The first field report will be appended here when it lands.&lt;/p&gt;

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



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/xxmasy/lkio.git &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;lkio
uv &lt;span class="nb"&gt;sync&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; uv run lkio verify &lt;span class="nt"&gt;--all&lt;/span&gt;   &lt;span class="c"&gt;# 11 verification gates, ~2s, all green&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Star it, break it, file issues. Contact: &lt;a href="mailto:812866097@qq.com"&gt;812866097@qq.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Roadmap: SQLite-backed zero-dependency mode, more languages, and a hosted option&lt;br&gt;
for teams that don't want to self-host.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/xxmasy/lkio" rel="noopener noreferrer"&gt;https://github.com/xxmasy/lkio&lt;/a&gt;&lt;/p&gt;

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