Optimal Context Mapping · Model D

AI on your codebase.
A bill that flattens.

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.

2.3–2.8×cheaper per question on a company's own repository, with a five-person team asking
$11.56 → $4.20the API bill for the same 228 questions, at the same accuracy
5–10×cheaper when a question is asked again, in other words

How it works

Deterministic first.
Model second.

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.

Step 1

Map once

Your repositories are mapped one time, on your own machines. Your code never leaves.

Step 2

Decide in bits

Before each request, the deterministic layer decides which code answers it. Zero tokens, a fraction of a second.

Step 3

The model reads

The model is the semantic layer and the eyes: it understands the question and reads the code it was handed.

Step 4

It learns

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 real work.

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

Where a team works, it pays most.

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.

Cost per question, agent alone$0.0276
Model D, strict reader$0.0118
Judged right, agent alone86%
Judged right, Model D84%
2.34× cheaperTeammates' repeats: 3.5× cheaperSaving grew 2.66× → 3.17×

Proof: plan · strict reader · every answer and verdict

228 questions · one stream · Claude API

The bill bends flat.

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.

$11.56 → $4.20
the whole stream, agent alone → Model D, 215 and 213 right
Per question, second half, agent alone$0.069
Per question, second half, Model D$0.013
A question it has learned$0.0005

Proof: plan · first 114 · reworded 114

114 real Django bugs · SWE-bench Lite · three runs

Even scattered bugs cost less.

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.

Requests per bug, agent alone4.03
Model D2.54
Cost per bug, agent alone$0.033
Model D$0.024
Right: 325 → 321 of 34257 misleading lessons: 0 false reads

Proof: plan · rows e1, f1_r2, f1_r3, e3, e5, f4

Ten years of Django · 5,333 real fixes

It knows where to look. Before it learns anything.

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%.

84%
right file shown, deterministic layer alone
Deterministic layer83.9%
Five most-edited files13.9%
Questions on learned ground, 2013 → 202342% → 70%

Proof: plan · results and limits

Repeated questions · Gemini 2.5 Flash, three runs

The second time, it's one read.

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.

Per questionAgent aloneWith the layer
Requests, learned question5.1–5.41.0–1.1
Tokens, learned question118k–141k1.2k–1.4k
Tokens, first time asked126k–165k6k–12k
Bill, whole stream1×6–12× lower

Proof: plan · report

Every kind of agent work · Claude API

The more the agent works, the more it saves.

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.

TaskFirst timeAsked again
Research with web search2.3×9.8×
Deep research: code + docs + web2.2×9.4×
Deep web research from tickets1.3×5.4×
Bugs in seven more codebases1.3–1.5×–
Maximum-effort thinking, hardest bugs1.2×–
Writing the fix, Django's own tests1.2× per fix–
Cost saving against the same agent alone, list price, from the API's own usage fields.

Proof: plan · rows e6, f3, g1, g3, e5, f4, w

The math

Why skipping a step saves more than a step.

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.

The cost of a session
T(r)=rP+gr(r−1)2

r turns, a fixed prompt P re-sent every turn, and g tokens added by each step.

The turn law
Sturns=raq+(1−φ)(ra−q)

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.

With learning
S(n)=A(1−ν(n))E+ν(n)K

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

Measured. Written down first.
Checked twice.

Fixed before it ran

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.

Checked independently

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.

What failed

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.

Where it grows

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

Works with the agents your team already uses.

One command wires it into a repository. It runs on your machines, so your code stays yours.

Bring it to your codebase.

If the token bill is what's keeping AI out of your team's workflow, let's measure it on your own code.