Optimal Context Mapping · Model D
Model D fuses a deterministic kit with the Claude API you already use. The kit maps your code once and takes the expensive decisions at zero model cost. Claude reads what the kit already knows and explores only what is new, and every exploration teaches the kit.
How it works
Every AI coding agent pays for thinking twice: once to work out where to look, then to reason about what it found. The first part is search, and every search step re-sends the whole conversation. That is where the tokens go.
Your repositories are mapped one time, on your own machines. Your code never leaves.
Before each request, the deterministic layer decides which code answers it. Zero tokens, a fraction of a second.
The model is the semantic layer and the eyes: it understands the question and reads the code it was handed.
When something is new, the place it was found is learned, so the next engineer's question costs less. 99% of explorations left a lesson.
Results
Measured on the Claude API: a company-style repository with a team, 114 real bugs three times over, seven more codebases, research with web search, maximum-effort thinking, and fixes checked by the project's own tests. Every test plan was written and hashed before it ran. Every number links to its data, and one command recomputes them all.
A company's own repository · a five-person team · three runs
A lead, a backend developer, a frontend developer, DevOps and a new joiner asked 100 questions about a real application. A quarter were repeats in other words. Model D answered them for less than half the cost, and the saving grew as the team taught it. A blind judge graded every answer against the gold answer.
Proof: plan · strict reader · every answer and verdict
228 questions · one stream · Claude API
The 114 Django bugs, then the same 114 reported again in different words. The agent alone paid more for the reworded reports, because harder search costs more. Model D paid less, because 84 of them were answered by one cheap read of code it already knew.
Proof: plan · first 114 · reworded 114
114 real Django bugs · SWE-bench Lite · three runs
The hardest case: every bug is new and lands somewhere different in an 866-file codebase. Model D still needed 1.6× fewer requests and cost 1.35× less, at the same accuracy. On seven more codebases, from sympy to flask, it cost 1.3× to 1.5× less.
Proof: plan · rows e1, f1_r2, f1_r3, e3, e5, f4
Ten years of Django · 5,333 real fixes
Replaying 2013 to 2023 in order, the deterministic layer put the right file in front of the model 84% of the time, using about five files of context. Showing the five most-edited files instead finds it 14% of the time. As it learned from finished work, the share of questions landing on something it had already learned rose from 42% to 70%.
Repeated questions · Gemini 2.5 Flash, three runs
A question the layer has learned is answered by a single cheap read of the right code. Across whole streams of questions, the bill came out six to twelve times lower than an agent working alone.
Every kind of agent work · Claude API
Model D takes over the expensive decision of where to look, and the model keeps the craft. Research, web search and maximum-effort thinking make every agent turn expensive, so they save the most dollars per question. Earlier tests showed the same effect on Claude Opus and Gemini.
| Task | First time | Asked again |
|---|---|---|
| Research with web search | 2.3× | 9.8× |
| Deep research: code + docs + web | 2.2× | 9.4× |
| Deep web research from tickets | 1.3× | 5.4× |
| Bugs in seven more codebases | 1.3–1.5× | – |
| Maximum-effort thinking, hardest bugs | 1.2× | – |
| Writing the fix, Django's own tests | 1.2× per fix | – |
Proof: plan · rows e6, f3, g1, g3, e5, f4, w
The math
Each turn re-sends everything before it, so a session's cost grows with the square of its turns. Take away the searching turns and the savings compound.
r turns, a fixed prompt P re-sent every turn, and g tokens added by each step.
The layer takes over a share φ of the agent's search turns. With φ = 0.57 fixed in advance, it predicted Model D's requests within 10% on 114 real bugs and within 4% on a company repository.
As novelty ν falls, more questions cost one read E instead of a full exploration K. A is what the agent spends alone. Teaching cost less than working alone (K < A) in 11 of 12 test sets, so the bill can only flatten. It predicted the saving on reworded questions within 11%.
Tokens fall faster than turns only when the context the layer avoids is bigger than the code it hands over. That condition called every dataset correctly. In long sessions the readouts pile up, so clear between tasks.
Proof: report keys M1 E1, M1 V4, M3 E2 · verify.py checks K < A in each set · formula
Honest numbers
53 test plans, each written and hashed before its first model call. In the latest program on the Claude API ($142 of credit), 31 of 45 predictions held and 14 failed.
Independent audits recomputed the key numbers from the raw logs and reproduced them. The data is now public, and evidence/verify.py recomputes every number on this page.
Reports with every code name removed lose accuracy. Long sessions don't compound the saving. Writing fixes is cheaper per fix, but not yet proven at 19 issues. Basics guessed from old commit messages didn't beat a cold start.
On brand-new, scattered work the floor is about 1.35×. The more your team works the same code, the more it saves: 2.3–2.8× on a company repository, and 5–10× on repeats.
Fits your stack
One command wires it into a repository. It runs on your machines, so your code stays yours.
If the token bill is what's keeping AI out of your team's workflow, let's measure it on your own code.