The Same Answer For 16x Less Context
pip install awgraph now gets you the code knowledge graph our agents use instead of
grepping. It indexes a repository into symbols — functions, methods, classes, their
calls and callers — and answers a natural-language question with the handful of chunks
that question actually needs.
The headline, measured over 33 real commits:
awgraph reaches the same retrieval recall as exhaustive grep — 1.000 — using 16x less context. At every budget in between it costs 16 to 268x fewer tokens.
| k | awgraph recall | tokens | grep recall | tokens | cheaper |
|---|---|---|---|---|---|
| 10 | 0.803 | 1,311 | 0.924 | 351,427 | 268x |
| 25 | 0.939 | 3,132 | 0.985 | 504,640 | 161x |
| 50 | 0.939 | 6,158 | 1.000 | 668,299 | 109x |
| 100 | 0.939 | 12,059 | 1.000 | 735,727 | 61x |
| 200 | 0.939 | 23,386 | 1.000 | 735,727 | 31x |
| 400 | 1.000 | 45,269 | 1.000 | 735,727 | 16x |
Why this is the number that matters
Read the shape honestly, because it is more interesting than "we beat grep."
grep is the better finder at any matched budget. It reaches perfect recall at k=50 while awgraph is still at 0.939. We are not claiming to be more accurate.
The claim is about what perfect recall costs. grep gets there by spending 668,299 tokens per task — more than most models will accept in a single window at all. The argument was never that grep is inaccurate. It is that at full recall, grep does not fit.
That distinction matters because of where the budget actually goes. An agent loop is not one query; it is dozens of turns, each of which has to leave room for the code it is about to write. A retriever that answers correctly and consumes the entire window has not helped. One that answers as well for 3,132 tokens leaves the window free for the work.
What the benchmark actually measures
The task is a real commit message with the answer filenames stripped out of it. The truth is the set of files that commit actually modified.
Stripping matters more than it sounds. Leave the filenames in and the task becomes
grep <filename>, which the baseline wins by construction while measuring nothing at
all. That is the easiest way to write a retrieval benchmark that produces confident
numbers about nothing.
Both retrievers are confined to the same subtree, so they search the same universe. Neither ever sees the truth set while retrieving.
The rigged version we caught ourselves publishing
This is the part worth your time.
The first thing we published said "86% of grep's recall for 0.43% of the context" — a cost win with a recall loss. That comparison was made at the same rank depth, not the same budget. At k=10, grep returns ten whole files (~351k tokens) and awgraph returns ten chunks (~1.3k). We were asking the graph to win on recall while working from 0.4% of the evidence, and then reporting that it lost.
So we swept the budget. The graph hit 0.939 at k=25 and 1.000 at k=400, and the sweep printed a beautiful headline: beats grep's recall at 112x less context.
It was wrong, and the reason is one line in the baseline:
ranked = [f for f, _ in scores.most_common(k)]
k bounds grep's output too. We had swept the budget for our own arm and left the
baseline pinned at ten. That is a graph given 400 results competing against a grep held
to 10 — and the "win" evaporated the moment the baseline could spend the same budget.
grep does not merely stay competitive; it reaches 1.000 first, at k=50.
The tell was not in the results table. A one-armed sweep and a fair one produce output that looks identical — clean columns, plausible curve, monotonic improvement. The only place the defect was visible was in the baseline's source. Before believing any top-n or budget sweep, read the arm you are not rooting for and check whether the parameter you varied also bounds it.
The sweep now runs both arms at every k, states its claim against grep's best recall at any k rather than its value at the base setting, and carries the reason in the function so it cannot be quietly undone.
Do the embeddings earn their keep?
awgraph does hybrid retrieval — keyword plus semantic — and embedding a codebase on CPU is the slow part of setup. So: does the semantic half do anything?
We had a reason to doubt it. A run logged 17 query-embedding failures, and we reported the semantic half as "intermittently off." That was an inference from a log line, not a measurement. Ablating it settles it — same 33 tasks, same index, semantic half disabled:
| k | keyword only | with embeddings | gain |
|---|---|---|---|
| 10 | 0.682 | 0.803 | +0.121 |
| 25 | 0.818 | 0.939 | +0.121 |
| 50 | 0.909 | 0.939 | +0.030 |
The embeddings work, and they earn their keep precisely where it counts: at small k,
which is the entire point. The warnings were transient, and our earlier claim overstated
them.
The half that cuts against us is worth publishing too: the gain narrows as the budget grows. A caller happy to spend k=50 can skip the CPU embedding step and lose 0.03 recall. If you are optimising for the cheap end of the curve, embed. If you are not, do not bother.
Two things we tried that did not work
A benchmark that only reports its wins is an advertisement.
Embedding coverage was not the gap. We assumed our recall was understated because only 33.3% of chunks carried vectors on an early run. Going to 100% coverage moved recall@10 from 0.800 to 0.803. The hypothesis is refuted, and the caveat claiming it understated the result has been removed.
Naive fusion failed. The obvious idea: run the graph, fall back to grep when it returns few files. Measured 0.894 recall at 348,389 tokens — worse recall than grep and nearly its full cost. The trigger is why. Keyed on result count, the fallback fires when the graph is confidently wrong and stays quiet when the graph is confidently right — the exact inverse of useful. Keying it on score instead is untested.
Use it
pip install awgraph
awgraph index .
awgraph query "retry with exponential backoff"
awgraph callers send_request
awgraph stats
query prints path:line and the signature, so results paste straight into an editor.
--json on any read command wires it into a tool loop. Exit codes distinguish 0
success, 1 nothing matched, and 2 could not run — so a caller can tell "no
results" from "there is no index yet," which are different problems with different
fixes.
awgraph stats always prints embedding coverage, including 0.0%. Without a backend,
hybrid search silently degrades to keyword scoring and still returns ten confident-looking
results. Whether the semantic half is on should never be a question you answer by
reading source.
Where it sits
Three packages, three different questions about one repository. awgit knows what changed and who is editing it. awgraph knows what the code is and what depends on what. awdk is the agent runtime that consumes both. All Apache 2.0.
The caveats
n=33, one repository, Python only, and k is a budget the caller chooses rather than
something the tool tunes for itself.
One more, and it is the one a skeptic should push on: awgraph's token counts are previews — signature, docstring, and a body excerpt per chunk. An agent that then reads the full body of its top hits pays more than the figure in the table. grep's number is whole files, which is what an agent genuinely has to read. The comparison is fair at the retrieval step and generous to us after it.
And the honest gap: we measure files retrieved, not tasks resolved. Those are different axes, and closing it means running an agent loop end to end. That is the experiment we have not run yet.
Everything above reproduces from codegraph_task_context_ab.py --embed --sweep 10,25,50,100,200,400, and the live numbers are at
aitherium.github.io/awgraph.
Keep the journal free
Sponsorship pays for the compute, the hardware and the hours behind these entries.
by email
New journal entries, in your inbox.
What the agents built, broke and fixed. One message per entry.