Field guide · 22 sources

Field guide: Knowledge and code graphs

Whether code graphs, knowledge graphs, ontologies, indexes and retrieval models help agents compared with grep and plain RAG, and what the evidence actually measures.

Bottom line

Use grep and file reads as the baseline for giving an agent knowledge. Add a code graph, knowledge graph, ontology or vector index only after it beats that baseline on held-out questions from your own corpus, scored on answer correctness as well as on tokens and time. Enforce access control in the retrieval path the agent actually calls, and check each interface it can reach. Treat the published figures as early evidence, mostly measured by the people who built the tools.

The default these sources describe is lexical. Wavestone's source-code survey of eleven agent systems found that none uses vector-embedding code retrieval (R054-f1), and it recommends no code RAG unless it beats ripgrep plus tree-sitter on a held-out set (R054-f5). That survey reads source code and runs no head-to-head comparisons (R054-f1). In a separate study of agent memory, the authors gave the agent a regex search over a verbatim log of its own history, with no embeddings or index (R230-f1). After RL training, that setup had the highest mean accuracy across their five tasks, 66.4 percent against 56.3 for MemGPT-style memory (R230-f4). It was one 9B model and one trained run per strategy (R230-f6).

The code-graph evidence is thin and vendor-run, and CodeGraph's figures report tokens and cost rather than answer quality (R134-f2). CodeGraph's authors asked one architecture question on each of 7 repos, with Opus 4.8 and a median of 4 runs per arm (R134-f1). Against the same Claude Code setup with CodeGraph blocked (R134-f4), they report 88 percent fewer tool calls, 62 percent fewer tokens and 44 percent lower cost on average (R134-f2), and the claims extracted report no answer-correctness score for those runs. Graphify's only code benchmark is 6 questions on one repo, where its authors report 82.0 percent key-fact coverage against 70.8 percent for a grep and read baseline (R076-f3). Trail-code, which injects learnings seeded from past sessions and PR comments rather than a code graph (R199-f4), reports 33 of 50 SWE-bench Verified instances resolved against 27 of 50 without it, with one model, in its authors' own run (R199-f2).

Keep conversational-memory benchmarks separate from code. On LOCOMO, Graphify's recall lead over supermemory came with lower QA accuracy, though it scored above mem0 (R076-f1). Its recall at 10 was 0.497 against 0.149 for supermemory and 0.048 for mem0, and its QA accuracy was 45.3 percent against 49.7 and 27.3 (R076-f1). On LongMemEval-S, with 50 questions, it ties dense RAG at 76 percent (R076-f2). A retrieval lead did not give Graphify the best answers in those runs (R076-f1) (R076-f2). The retrieval-model results are the authors' own figures on public benchmarks such as BEIR and MMTEB (R261-f1) (R137-f1) (R171-f1), and none of those claims involves an agent.

Most entries here rest on READMEs or model cards, one is a LinkedIn post with no data (R204-f3). Claims from these sources carry less weight below.

Decide first

QuestionIf yesIf noEvidence
Are the questions about code structure in a repository, such as architecture or callers?Start with grep and read, and trial a code graph only on your own held-out questions, scoring correctness as well as tokensCode-graph results do not apply(R054-f5) (R134-f1) (R134-f2) (R076-f3)
Is the knowledge in long, structured documents such as filings?Consider tree navigation over sections, and check cost against sending the document natively; local PageIndex handles text PDFs onlyThe PageIndex results do not apply(R010-f3) (R010-f4) (R010-f6)
Is the knowledge in a relational database with relationships nobody declared?Give the agent search tools and a schema it can inspect; inferred ontologies have only a demo behind them hereSchema-only prompting scored well below search tools in one authors' benchmark, so give search tools either way (R070-f3)(R070-f3) (R028-f1) (R028-f2)
Do the questions need corpus-wide synthesis rather than one fact?A graph built over the corpus raised coverage in one authors' study, at lower chunk precisionVector RAG kept higher chunk precision in that study(R127-f2) (R127-f3)
Do different users have different rights to the data?Enforce policy at retrieval, and confirm it covers every interface, including MCP and vector search, and runs as the end userA single service identity may be enough(R183-f2) (R256-f3) (R074-f1)
Does the source data change while agents work?Learn each index's refresh model and surface staleness to the agentA snapshot index is enough(R028-f4) (R256-f2) (R134-f6)
Does the agent need its own history from beyond its context window?Try lexical search over a verbatim log alongside summarisation before building a memory store; the evidence is one RL-trained 9B modelSummarisation may be enough(R230-f1) (R230-f2) (R230-f6)

Do

  1. Make grep and read the baseline you have to beat. Wavestone's survey found no studied harness using vector-embedding code retrieval (R054-f1), and its test for code RAG is a held-out comparison against ripgrep plus tree-sitter (R054-f5). Graphify's code benchmark used a grep and read baseline (R076-f3), and CodeGraph compared against the same harness with its tool blocked (R134-f4). Both rest on few questions, 6 on one repo (R076-f3) and one on each of 7 repos (R134-f1), and the claims do not say whether either set was held out.

  2. Score retrieval and answers separately, then report both. Graphify's LOCOMO recall was about three to ten times the comparison systems', while its QA accuracy was lower than supermemory's (R076-f1). GraphRAG Zero raised global assertion coverage from 53.4 to 57.4 percent over vector RAG (R127-f2), while vector RAG kept higher chunk precision (R127-f3). AutoRAGBench scores retrieval systems through five held-out small answering models, so that retrieval quality rather than the answerer is measured (R211-f1). A practitioner post also says to measure retrieval alone with recall at k before tuning chunk size, though it offers no data (R204-f1) (R204-f3).

  3. Read code-graph savings as tokens, time and cost on single questions. CodeGraph's averages hide wide per-repo spread: cost savings ran from 78 percent on Excalidraw to about even on Gin, while Gin and Django still used 52 and 41 percent fewer tokens (R134-f3). Its authors block the tool in the baseline arm; on an unblocked harness 26 of 28 baseline runs used it through Bash, and earlier published figures lacked the block (R134-f4). Trail-code, which injects learnings seeded from past sessions and PR comments rather than a code graph (R199-f4), covered on its own harness 162 runs on 2 repos at equal average correctness of 93 percent, and the push mode lost 3 correctness points on one corpus (R199-f1).

  4. Have the agent look things up rather than recall them. This is an analogy from a clinical-coding extraction task, not a retrieval-for-agents result. There, codes recalled from memory included 13 to 18 percent that exist in no release, and picking from 20 retrieved candidates scored about ten times higher, on 40 development documents over three runs (R039-f3). In a data-analysis benchmark, Opus 5.5's execution accuracy rose from 54.6 with schema only to 86.6 with search tools, in its authors' runs over 256 tasks (R070-f3).

  5. Give the agent search tools, and add file access only if it pays for its extra tokens. In that data-analysis benchmark, one retrieved document added at most 1.5K tokens for a 9 to 17 point gain, while file and CLI access cost 2.2 and 2.6 times the input tokens per correct answer of search tools without better accuracy (R070-f6). In PageIndex's README, native PDF input cost 2.1 times its retrieval at 52 pages and 16.6 times at 420 pages, with prompt caching excluded and few documents (R010-f4).

  6. Expect accuracy to depend strongly on the model and effort setting. On PageIndex's own financial-qa benchmark, Sonnet 5.5 ranged from 82.0 percent at high effort to 98.0 percent at max, a vendor-run figure (R010-f2). The top configuration reached 99.0 percent at 10.73 dollars per 100-question run, a vendor-run figure (R010-f1).

  7. Enforce access control in the retrieval path, and check what the policy covers. TrustGraph evaluates SHACL policies per node as Allowed, Filtered or Violation, with a per-request user context and audit events (R183-f1). Its README states that policy for REST, SPARQL and GraphRAG but does not state it for MCP, vector search or DocumentRAG, and the default is open mode with no policies (R183-f2). In OntoBricks, the MCP guide's machine-to-machine connection shares one service-principal identity for all users, so per-user access control needs OAuth user-to-machine (R256-f3). Omnigraph's MCP tools run the same Cedar action as its HTTP routes, so policy alone decides what an agent may run (R074-f1), and its release notes tell operators to keep an agent read-only by narrowing its policy and giving it its own credential (R074-f2). auto-ontology-mcp drops RBAC and PII detection (R028-f5) and stores datasource passwords in plain text (R028-f3).

  8. Know how each index stays fresh. auto-ontology-mcp does not watch files, so passages go stale unless the agent re-reads changed documents and saves them again (R028-f4). OntoBricks reads live rows only in Lakehouse view mode, and in table mode its Explorer and raw SPARQL can disagree until a full Build (R256-f2). CodeGraph runs a file watcher with a staleness banner and reconciles on connect (R134-f6).

  9. Guard agent writes to a graph store. Relate's opt-in safe mode refuses unlabeled CREATE and MERGE and MATCH without LIMIT, but it is off by default and never auto-detected (R055-f3). Relate keeps the whole graph in RAM in one process and has no general write-skew detection (R055-f4). TrustGraph's extraction rejects triples that violate domain, range and subclass constraints, though it is not a full OWL reasoner (R183-f3). No source here measures whether this changes agent outcomes.

  10. Keep provenance and confidence with what the graph returns. Graphify tags each edge EXTRACTED or INFERRED with a confidence tag and rates a path by its weakest hop (R076-f5). TrustGraph records provenance with PROV-O and writes retrieval traces to a named graph (R183-f3). No source here measures whether these tags change agent outcomes.

  11. Keep tool definitions small. auto-ontology-mcp's authors report that one toolset setting cuts the tool definitions the model sees from about 52,000 to about 12,000 characters (R028-f6). Relate caps agent-mode output at 100 rows with the truncation stated in-band and returns structured JSON errors (R055-f2). No source here measures whether this changes agent outcomes.

  12. Choose embedding and retrieval models on your own retrieval task, not a leaderboard average. blink-multilingual-64M's author reports an MMTEB v2 average of 51.60 against 48.37 for a truncated rival at 256 dimensions (R137-f1), yet its retrieval score is 47.52 against 47.62, so the gain lies outside retrieval (R137-f2). SPARSEUP-v2's authors report BEIR-15 nDCG@10 of 57.2 against 50.5 for SPLADE-v3 (R261-f1), but it leads only 5 of 10 beyond-BEIR sets on nDCG@10 (R261-f3). NeuML's Atto models are averaged over three small BEIR datasets (R171-f1), and the 110M reference baselines score above every Atto model (R171-f2).

  13. If an agent builds the retrieval pipeline, test it on data it never saw. In AutoRAGBench, 72 of 77 builds improved on development checks, yet the model with the largest median development gain ranked tenth on hidden tests (R211-f6). Every agent-built system retrieved slower on average than the reference, 0.50 to 2.01 seconds per question against 0.35, a figure excluded from the score (R211-f5).

Avoid

Where the evidence disagrees

DisagreementSide ASide BWhat reconciles itWhat would settle it
Do code graphs beat grep and read for code questions?CodeGraph's authors report 62 percent fewer tokens and 44 percent lower cost (R134-f2), and Graphify's report 82.0 against 70.8 percent key-fact coverage over grep and read (R076-f3)Wavestone's source-code survey found no studied harness using vector-embedding code retrieval (R054-f1) and recommends no code RAG unless it beats ripgrep plus tree-sitter on a held-out set (R054-f5); it makes no statement about code graphsThe graph results come from the builders on 7 single questions (R134-f1) or 6 questions on one repo (R076-f3), and CodeGraph's figures measure cost rather than correctness (R134-f2); applying Wavestone's code-RAG bar (R054-f5) to code graphs is this guide's extensionMany held-out questions per repo, graph tool against ripgrep plus tree-sitter, scored for correctness and cost, run by someone other than the builder
Does graph retrieval give better results than memory systems or vector RAG?Graphify's LOCOMO recall at 10 was 0.497 against 0.048 for mem0 and 0.149 for supermemory, and its QA accuracy of 45.3 percent beat mem0's 27.3 (R076-f1); GraphRAG Zero raised global coverage from 53.4 to 57.4 percent over vector RAG (R127-f2)Graphify's QA accuracy was 45.3 against 49.7 percent for supermemory (R076-f1), it tied dense RAG on LongMemEval-S (R076-f2), and vector RAG kept higher chunk precision (R127-f3)Graphify's LOCOMO recall lead did not give it the best QA accuracy (R076-f1), and GraphRAG Zero reports coverage and precision but no answer-accuracy figure (R127-f2) (R127-f3)Retrieval and end-answer metrics reported from the same runs, on the same corpus, by independent evaluators
Do agent-built RAG systems beat a strong reference?All nine agent configurations beat BM25 and seven beat a hybrid-plus-reranker reference on average (R211-f2)On NQ and FEVER the largest gain over the reference was 1.5 points, and on MH-RAG four agent systems scored below BM25 (R211-f3)Gains were uneven by task, with every configuration beating the reference on WebQSP by 14.1 points on average (R211-f3)Per-task results with repeated builds and variance, on more datasets
Do OntoBricks graph tools run as the end user?The 0.9.2 release notes say graph tools run as the end user (R256-f3)The MCP guide's machine-to-machine connection shares the service-principal identity for all users (R256-f3)It depends on the connection type, and per-user access control needs OAuth user-to-machine (R256-f3)A documented test of which identity each MCP connection type uses for graph queries

Most measured results here come from the people who built the system or benchmark (R010-f1) (R076-f1) (R127-f2) (R134-f1) (R160-f2) (R199-f1) (R261-f1) (R137-f1) (R171-f1) (R211-f2) (R230-f2). The design and access-control material comes from READMEs and project docs (R028-f1) (R055-f1) (R183-f1) (R256-f1), vendor release notes (R074-f2), a source-code survey (R054-f1) and one practitioner post (R204-f1).

Numbers

ClaimResultValueConditionsWhere in source
(R134-f2)CodeGraph average reduction88% tool calls; 53% time; 62% tokens; 44% cost7 repos, one architecture question each, Opus 4.8, median of 4 runs per arm, vendor-runREADME benchmark table
(R134-f3)CodeGraph per-repo cost saving13% to 78%; Gin about evenSame runs; Django and Gin still 41% and 52% fewer tokensREADME benchmark table
(R134-f4)Baseline contamination0 of 28 after block; 26 of 28 used the tool when unblockedAuthors' own control; earlier figures lacked the blockREADME method note
(R134-f5)Residual retrieval context+82% averageclaude-sonnet-5, 3-turn sessions, 56 sessions; doc says not comparable to README tableresidual-context-occupancy.md
(R134-f6)CodeGraph index timeAbout 100 s for 27k files; under 12 min for 70k files2-core 6 GB VPS, authors' figuresREADME performance
(R076-f3)Graphify key-fact coverage, code82.0% vs 70.8% (grep and read)ERPNext, 6 questions, authors' ownREADME benchmarks table
(R076-f1)Graphify LOCOMORecall at 10 0.497 vs 0.048 and 0.149; QA 45.3% vs 49.7% and 27.3%300 conversational-memory questions, authors' own tableREADME benchmarks table
(R076-f2)Graphify LongMemEval-S QA accuracy76%, tied with dense RAG50 conversational-memory questions, authors' ownREADME benchmarks table
(R199-f1)Trail-code with push32% cost; 42% uncached input; 46% tool calls; 60% latency; correctness 93% both armsAuthors' harness, Sonnet 5, Opus 4.8 judge, 162 runs, 2 reposREADME benchmarks
(R199-f2)Trail-code on SWE-bench Verified33/50 vs 27/50 resolved50-instance subset, Sonnet 5, efficiency over instances both arms resolved, authors' ownREADME SWE-bench section
(R199-f3)Trail-code on PocketBase21% lower cost; 14% less time15 tasks, one repo, authors' ownREADME PocketBase section
(R010-f1)PageIndex financial-qa top configuration99.0% at 10.73 dollars per run100 questions, 40 10-Ks, at least 3 runs, vendor-run; README text and benchmark repo give different configuration countsfinancial-qa README
(R010-f2)Sonnet 5.5 range on the same benchmark82.0% to 98.0%Effort high to max, vendor-runfinancial-qa README results table
(R010-f4)Native PDF cost vs PageIndex2.1x at 52 pages; 16.6x at 420 pagesPrompt caching excluded, few documents, vendor READMEREADME cost comparison
(R127-f2)GraphRAG Zero global coverage53.4% (vector RAG) to 57.4%; 0.93 s context preparation200 synthetic questions, 50-chunk budget, one response per query, Microsoft Research authorsMSR story study section
(R127-f4)LazyGraphRAG indexing cost0.1% of full GraphRAGAbout 1,400 news articles, 200 questions, Microsoft ResearchMSR story background
(R160-f2)AtlasKV top-1 grounding accuracy21.8 vs 9.1 (KBLaM) at 10,000 triplesEnron, LLaMA3.1-8B, authors' own, not tested beyond 10^4Sec 4 tables
(R160-f3)AtlasKV VRAMUnder 20GB at 1B triplesMemory only, accuracy not measured at that scale, authors' ownFig 4
(R028-f2)auto-ontology-mcp demo9 undeclared foreign keys; 7 acceptedSynthetic database, 11 tables, one run, not a benchmarkREADME demo
(R028-f6)Tool definition size52,000 to 12,000 charactersAuthor figure, not independently measuredREADME toolsets
(R261-f1)SPARSEUP-v2 BEIR-15 nDCG@1057.2 vs 50.5 (SPLADE-v3); FLOPS 4.2 vs 6.2 (v1)Authors' card, English only, vendor-runHF card results
(R261-f2)Larger sparse modelsLACONIC-8B 60.1; LACONIC-3B 58.3Authors' own comparison tableHF card comparison table
(R261-f3)SPARSEUP-v2 beyond-BEIR wins5 of 10 (nDCG@10); 5 of 12 (recall at 100)Authors' own tablesHF card beyond-BEIR table
(R137-f1)blink-multilingual-64M MMTEB v251.60 vs 48.37131 tasks at 256 dimensions, author's own cardHF card results table
(R137-f2)blink retrieval score47.52 vs 47.62Same cardHF card breakdown
(R171-f1)Atto nDCG@100.4892 vs 0.4802 (all-MiniLM-L6-v2)ArguAna, NFCorpus and SciFact only, vendor-runNeuML blog results
(R171-f2)110M reference baselines0.5638 and 0.5463 vs best Atto 0.5138Authors' caveatsNeuML blog caveats
(R211-f2)AutoRAGBench averageBM25 36.7; reference RAG 46.4; best agent 56.1Nine RAG tasks, five answering models, authorsAutoRAGBench results
(R211-f3)Per-task gains over referenceWebQSP +14.1 average; NQ and FEVER at most +1.5Same nine configurationsAutoRAGBench per-task results
(R211-f5)Retrieval latency0.50 to 2.01 s vs 0.35 sMeasured but excluded from the scoreAutoRAGBench Sec VI-C
(R070-f3)Execution accuracy by data contextOpus 5.5 54.6 (schema only) to 86.6 (search tools) to 88.8 (files and CLI)256 data-analysis tasks, three runs each, authors ran the modelsSynthCorp results
(R070-f6)Cost of file access2.2x and 2.6x input tokens per correct answer vs search toolsOpus and DeepSeek, no accuracy gain, authorsSynthCorp results
(R230-f2)Grep over verbatim history, exact recall97.4% (KV Store) and 95.3% (Log Triage) vs 13.9% and 6.6% for summarisation; MemGPT-style 99.9% and 50.0%Qwen3.5-9B after RL, one trained run per strategy, authors' ownGrepMem Table 3
(R230-f4)Mean accuracy across five tasks66.4% vs 56.3% (MemGPT-style)After RL, authors' ownGrepMem results
(R039-f3)Recall from memory vs retrieved candidates13 to 18% invented codes; about 10x higher with 20 candidatesClinical-coding extraction, 40 documents, three runs, authorsArticle system under test

How this was made

Twenty-two sources were used.

A Sonnet model extracted 74 claims for the graphs set, each tied to a location in its source. Opus wrote this guide from those claims and the related claims.

Limits, and how they were weighted:

Checking the sources found several of our earlier entries wrong, overstated or unverifiable. For example:

Those entries have been corrected at the source.

Sources in this guide

A field guide synthesizes the Research entries it cites. Each claim id links to the entry it comes from.