Case Closed by Schema: Building an Ontology a Chatbot Can Reason Over
in Blog
In the BBC’s Sherlock, Holmes keeps what he knows in a mind palace, an imagined building where every fact has a room of its own, so that when a case calls for it he can walk straight to the right door. Outside fiction, the closest tool we have is an ontology. If you wanted to build a mind palace for a problem of your own, you would start by devising a schema of the things that matter to it, how they may relate to each other and what counts as evidence for a fact, and then fill that schema with what your documents actually say, so that a person or a program can go straight to the fact it needs instead of searching the text again.
Given that idea, I wanted to see what it takes to build one end to end on a real problem, and whether it pays off once a chatbot sits on top of it. I picked a problem with a known answer: The Curzon Street Kidnapping, case 1 of the board game Sherlock Holmes Consulting Detective: The Baker Street Irregulars, in which a governess is snatched from a London street in November 1885 and released a day later, and the players, as Holmes’s street urchins, have to work out who took her and why by visiting addresses on a map of the city and listening to witnesses who do not always tell the truth. The video below is the end result, a small web app that shows the case as a graph, a map, a timeline and a list of testimony, with a chatbot that answers from it. (Spoiler warning: the last minute shows the solution.)
This post walks through the build in the order it happened. First, I separate the ontology, which is the schema, from the graph, which holds its instances, because everything after depends on that line. Second, I build the knowledge model as a pipeline of stages in which code, an LLM and a person each have their part. Third, I put a chatbot on top and show exactly what it is given. Last, I run an experiment on the best way for a model to consume the graph. You only need to read Python and to have called a chat API once; no graph database or ontology background is assumed. The code is on GitHub, although the game text is copyrighted, so the repository holds the code and text-free copies of the graph rather than the transcriptions.
- Why a Detective Board Game
- Schema Is Not Graph
- Part 1: Building the Knowledge Model
- Part 2: A Chatbot on Top of the Model
- Part 3: How Should a Model Consume the Graph?
- Closing Thought
Why a Detective Board Game
I chose a detective board game because it puts an ontology under exactly the pressure a real project would, at a size one person can still check. Everything the players can know comes in four pieces, shown in Figure 1: a casebook with the introduction to the case and one entry, called a lead, for each address the players can visit, a single front page of The Times, a sheet of informants, and a map of London on which every building has a number.
Fig. 1. Everything the players get for this case, photographed with a phone. These four components are the whole world the ontology has to describe, and the photos are where the pipeline in Part 1 starts.
- It is a closed world. If a fact is not in those four components, it does not exist, so there is never an argument about what the graph should contain.
- The sources disagree. Each lead is a visit to an address where somebody talks, and people lie, misremember, repeat rumours and contradict the newspaper, so a knowledge model that flattens everything into plain “facts” fails at once.
- It has an answer. The case ends with a set of questions about who did it, why and how, and the box contains the official solution, which gives the last part of this post a real yardstick: given the graph, does a model actually solve the case?
Throughout the post, a source means one self-contained piece of text: the introduction, one lead, or one item in the newspaper. The case has 76 of them with 389 paragraphs between them, which is small enough to hold in your head and large enough that nobody wants to cross-reference it by hand.
Schema Is Not Graph
The first thing I had simplified, and the distinction the rest of the post rests on, is that the ontology and the knowledge graph are two different objects.
- The ontology captures the world of entities you deem relevant to solving your problem: which kinds of things exist, how they may connect, and what counts as support for a fact. It is small, and a person writes it.
- The graph holds the instances, the particular things that exist in this case and the facts about them. It is large, and a pipeline produces most of it: here, 2,786 nodes and 7,502 edges.
For a kidnapping, the world that matters is made of people, organisations, places, objects and documents, the events that happen between them, and three kinds of fact:
- a relation between two entities, drawn from a fixed vocabulary (
parent_of,employed_by,resides_at,acquainted_with, and so on, withotherplus a free-textdetailas the escape hatch); - an attribute of one entity, such as
occupation: governessorhabit: smokes cigars; - an event, a scene-level happening with a type, a date, places, objects and participants in roles such as
victim,perpetratororwitness, which may itself be part of a larger event.
The graph is what you get when that schema is filled in for one case. Person belongs to the ontology, while person:wendy_sturton, the governess, belongs to the graph; employed_by belongs to the ontology, while the edge saying that Wendy works for the Train household, according to the introduction, belongs to the graph. Figure 2 shows the instance side as the app draws it.
Fig. 2. The graph at the “Key” detail level: only entities named in at least two sources, and events tied to at least three of them. Shape encodes the entity type from the ontology, and line style encodes how well a fact is supported (solid for observed, dashed for claimed, red for denied), which the next section explains.
Selecting a node opens its profile, which is the clearest way to see one instance of the schema filled in. Figure 3 is Wendy’s: the names she goes by across the sources, a description of her from each source that mentions her, and her attributes, each with its own status.
Fig. 3. One instance of Person. Every line in the profile traces back to a source: the descriptions are labelled with the lead they come from, and each attribute carries a status, so “adores Duncan and Clarence” is only claimed and her attitude towards a constable is only speculative.
The ontology is the shape of what you can know. The graph is what you know.
One property of this ontology turned out to matter more than any other design choice: it is also the LLM’s output schema. Most of the graph is filled by an LLM that reads each source and writes down the people, events and facts it finds, a task I walk through with a real example in Stage 4. For that task, the ontology’s Pydantic classes are handed to the model as its structured-output format, and the API then constrains the model to produce JSON in exactly that shape. Here is the class for an attribute, as it is in the repository:
class Attribute(BaseModel):
"""A property of one entity: occupation, title, age, appearance, habit, health, origin, ..."""
subject: str = Field(..., description="Entity ref.")
attribute: str = Field(..., description="snake_case name, e.g. 'occupation', 'habit', 'health'.")
value: str
attestations: list[Attestation]
This has three consequences. The ontology cannot drift away from the code, because it is the code that the extractor has to satisfy. The field descriptions double as instructions, since the model reads them as part of the schema. And every answer the model gives fits the graph by construction, so the pipeline never has to repair malformed output. OpenAI’s structured outputs add one quirk, which is that every field must be required, so an optional value is written as “required but nullable” (date: str | None) rather than given a default. That looks odd in Python, but it is the right call, because it forces the model to say “unknown” explicitly instead of quietly leaving a field out.
Says Who? Facts Are Built From Claims
The most important idea in the ontology is that a fact in the graph is never entered directly. It is built up from claims, where a claim is one source stating something once: a character telling the players something, the newspaper printing it, or the narrator observing it. In the schema above, the list of claims behind a fact is the attestations field, and each claim records four things: the paragraph it comes from, the voice it is said in (the narrator, a character or a document), who says it, and whether they assert it, deny it or only speculate. A short quote from the paragraph is kept as well, and a script checks that the quote really occurs there.
The status of a fact is then derived from its claims rather than decided by anyone. A fact that someone asserts and someone else denies is disputed. Otherwise the strongest voice that asserts it wins: observed if the narrator saw it, documented if a document states it, claimed if only a character says it, and speculative if people only guess at it, with denied left for facts that nobody asserts. Because the status is computed, it changes by itself whenever a new claim arrives or two facts are merged, so a fact asserted in one lead and denied in another becomes disputed without anyone having to notice the clash.
In the graph, every claim made by a character or a document is also a node of its own, linked as (Person)-[:MADE]->(Claim)-[:ABOUT]->(Event) and pointing to the paragraph that supports it. That is why Claim, with 1,152 nodes, is the largest type in the graph. It turns “who said what, and does it contradict what someone else said?” into a query rather than a re-read of the whole case, and the app’s testimony view in Figure 4 is nothing more than that query, grouped by fact.
Fig. 4. Facts whose claims disagree, each card listing who made each claim, their stance, the quote and the paragraph. The second card is a status that is wrong for an instructive reason.
A status is only as good as the claims behind it, and the second card in Figure 4 shows how it goes wrong. A witness at the address 63 NW confirms that the police have already questioned him and, in the next breath, says he saw nothing out of the ordinary that day. The extractor filed that second sentence as a denial of the questioning, so the event came out disputed by a single speaker who seems to disagree with himself. The derivation did its job, but the claim was attached to the wrong fact. The practical consequence: when a derived value looks odd, read the claims behind it first, because that is almost always where the error is.
Part 1: Building the Knowledge Model
The graph is filled by a pipeline of five stages. Some stages are plain code, two use an LLM, and the decisions that would create a fact are left to a person.
Fig. 5. The five stages that fill the graph, and who does the work in each. The backbone is the only stage with neither a person nor an LLM in it, and each of the two stages after it has a check that sends work back: code for extraction, a person for resolution.
- Digitise. Claude reads the photos of the game into text files with a fixed structure.
- Design the schema and a gold set. A person writes the ontology and the expected output for a few sources.
- Backbone. Code builds the part of the graph that needs no judgement: sources, paragraphs, leads and addresses.
- Extraction. An LLM reads one source at a time and fills the ontology, code checks the output against the text, and the gold set scores it.
- Resolution. Code merges what the sources say about the same thing into one node, and takes the extra merges an LLM proposes only once a person has accepted them.
Each stage writes a file that the next one reads, so any stage can be re-run on its own.
Stage 1: Digitise Into a Shape a Parser Can Read
The game is printed on paper, so the first job was to turn the phone photos from Figure 1 into text. The pages are curved and were photographed at an angle, so rather than run OCR, Claude read the photos.
The lesson of this stage is that the text has to be stored in a shape a parser can read without guessing. The casebook is kept as Markdown, which is easy for a person to read and correct, with a few strict conventions. Here is one complete lead, the short visit to 63 NW from Figure 4:
### 63 NW
An old man with a monocle and a limp answers the door, and looks us over. We ask him about
the day of the kidnapping. He shakes his head, "No, sorry. The police have already asked me
and I have told them as I tell you: I saw nothing out of the ordinary on that day."
<!-- page: 13 | source: PXL_20261124_131242624.MP.jpg -->
The heading is the lead’s id, which is also its address on the board: a building number and one of the map’s five areas (NW WC EC SW SE). Each paragraph below it is one block of text, and the HTML comment records which booklet page and which photo the text came from, staying invisible when the Markdown is rendered. A script parses this into JSON and numbers every paragraph, so this one becomes 63 NW#p1, the id that every fact taken from it will cite:
{ "id": "63 NW", "area": "NW", "number": 63, "pages": [13],
"paragraphs": [ { "type": "narrative", "text": "An old man with a monocle and a limp ..." } ] }
The rule I kept relearning is that a convention which cannot be checked by a regular expression will be broken somewhere in 389 paragraphs, so a heading that does not match the parser’s pattern is an error, not a warning.
The map needed a different format, because what matters there is not text but geometry. I stitched several photos of the board into one image, detected the numbered pins and traced the building outlines into vector shapes, which are stored as JSON coordinates rather than Markdown. For the ontology, the payoff is that every address on the board becomes a node with a position, so any place the text ties to an address can be drawn where it belongs, as in Figure 7.
Fig. 7. The board, redrawn as vector shapes rather than photo pixels. Dark pins are leads, outlined pins are informants, and the red badges count the events that happened at each address, which only works because places in the graph are linked to the address nodes built in Stage 3.
Stage 2: Design the Schema and a Gold Set
The ontology described earlier, with its entity types, its three kinds of fact and the claims behind every fact, is written entirely by a person, and this is the stage where most of the thinking went. Two choices about how to apply it shaped everything later. When building the graph, I model events at the level of a scene, such as a kidnapping with its abduction, captivity and release as sub-events, rather than every gesture, because events that are too fine turn the timeline into noise and events that are too coarse leave nothing to put in order. And when two mentions in different sources might be the same person but the text never says so, they stay apart, because a merge that turns out to be wrong invents a fact, and deciding it belongs to Stage 5, with the evidence in hand.
Alongside the schema, I prepared a gold set with help from Claude: a few sources for which we wrote out the expected output by hand. The input is a source’s text, exactly as the LLM will see it in Stage 4, and the output is what a careful reader would extract from it, written in the ontology’s own format, so the model’s answer and the gold answer can be compared item by item. Four sources (the introduction, two leads and a newspaper article) gave 67 entities, 45 relations and 29 events. I chose sources that share people and events on purpose, so that the gold set can also test whether Stage 5 merges the same thing correctly across sources, not only whether Stage 4 extracts it.
Stage 3: The Deterministic Backbone
The backbone is the part of the graph that follows from the structure of the material rather than from its meaning: each source and its numbered paragraphs, each lead and the address it sits at, and every address on the map. Code builds it from the files of Stage 1 before any LLM is involved.
It comes first because everything else hangs on it. Every fact the LLM extracts later cites a paragraph, and every place it finds may point at an address, so those nodes have to exist, and be right, before anything can attach to them. Because no judgement goes into the backbone, it can also be checked strictly, and the build stops whenever a link points at a node that does not exist or at an address that is not on the map. That strictness is what lets the later, less predictable stages rely on it.
Figure 6 shows the backbone around the lead from Stage 1. The solid boxes are everything code knows before any LLM has read a word: the lead belongs to the casebook, its one paragraph belongs to the lead, and the lead sits at an address with a position on the map. The dashed boxes are what the later stages hang on that skeleton, and every one of them attaches to a backbone node, either the paragraph it was read from or the address it stands at.
Fig. 6. The backbone (solid) and what attaches to it later (dashed), with the real ids for lead 63 NW. A newspaper item has no lead, so its paragraphs belong directly to the newspaper, as on the right. Extracted people and events point at the paragraph that mentions them, claims at the paragraph that supports them, and places at the address where they stand.
Stage 4: LLM Extraction, One Source at a Time
The LLM fills in the rest. The extractor makes one structured-output call per source, 76 calls in all, and each call asks the model to read a single source and return everything in it, in the shape of the ontology. Each prompt holds the extraction instructions, one worked example from the gold set (never the source being scored), a list of known entities (the informants and everyone from the introduction, so that the same person gets the same id in every source), and finally the source itself, one line per paragraph, each line starting with its paragraph id. For the lead from Stage 1, that last part is:
Unit: 63 NW (lead)
Board address of this lead (the scene place): 63 NW
[63 NW#p1] An old man with a monocle and a limp answers the door, and looks us over. We ask
him about the day of the kidnapping. He shakes his head, "No, sorry. The police have already
asked me and I have told them as I tell you: I saw nothing out of the ordinary on that day."
And here is part of what gpt-5.5 returned for it (26 November 2026; ... marks fields and items I cut):
{
"entities": [
{ "ref": "old_man_with_monocle", "type": "person", "name": "old man with a monocle and a limp",
"identified": false, "passages": ["63 NW#p1"], ... },
{ "ref": "police", "type": "organization", "name": "the police", ... },
...
],
"attributes": [
{ "subject": "old_man_with_monocle", "attribute": "health", "value": "has a limp",
"attestations": [ { "passages": ["63 NW#p1"], "mode": "narration", "asserted_by": null,
"stance": "asserts", "quote": "with a monocle and a limp" } ] },
...
],
"events": [
{ "ref": "police_questioning_of_old_man_about_kidnapping", "type": "legal",
"title": "Police questioned the old man about the kidnapping",
"participants": [ { "ref": "police", "role": "investigator", ... },
{ "ref": "old_man_with_monocle", "role": "witness", ... } ],
"attestations": [
{ "mode": "testimony", "asserted_by": "old_man_with_monocle", "stance": "asserts",
"quote": "The police have already asked me", ... },
{ "mode": "testimony", "asserted_by": "old_man_with_monocle", "stance": "denies",
"quote": "I saw nothing out of the ordinary on that day.", ... } ] },
...
]
}
Three sentences of text produced four entities, four attributes and two events. The limp is a claim in the narrator’s voice, so it is observed, while everything about the police comes from the old man himself, so it is at best claimed. The last claim is the mistake from Figure 4, caught here at the moment it was made: the model attached “I saw nothing out of the ordinary” to the questioning event as a denial.
Code checks every answer before it is accepted. Every quote must occur in the paragraph it cites, every entity a fact refers to must be declared, and no claim may cite a paragraph from another source. When any check fails, the errors go back to the model with a request for a corrected answer, up to two times. In the run I kept, all 76 sources passed, 7 of them after one round of repair. Answers are cached on a hash of the text and the whole prompt, so editing one transcription re-extracts only the sources it affects.
To score the extraction, I compare the model’s answer with the gold set, item by item. Take entities as the example. A predicted entity counts as a match, or true positive, when it lines up with a gold entity from the same source, judged by its name and by the paragraphs it cites (the ids themselves are free text, so they cannot be compared directly). Over the four gold sources, the model predicted 77 entities, the gold set has 67, and 64 of them match, which gives \[P = \frac{64}{77} = 0.83, \qquad R = \frac{64}{67} = 0.96, \qquad F_1 = \frac{2PR}{P + R} = 0.89\]
Precision asks how much of what the model found is right, recall asks how much of what it should have found it did find, and F1 balances the two. The same count, done for each kind of fact, gives this table:
| Entities | Relations | Attributes | Events | Participants | Event links |
|---|---|---|---|---|---|
| 0.89 | 0.68 | 0.42 | 0.82 | 0.70 | 0.29 |
Entities and events are reliable. Attributes and links between events score low mostly on precision, because the model extracts more than I did, adding extra habits and extra “related to” links, and some of those extras are real, since four hand-made sources are not exhaustive. On the facts that do match, the model agrees with the gold set on the voice and stance of a claim 96% of the time and on who made it 93% of the time, and for this graph those are the numbers I care about most, because every status is derived from them.
Stage 5: Resolution, Where the Human Decides
After extraction, the graph has one node for every source that mentions a thing, and the earlier stages point at where the work lies. Stage 4 showed that the model does not always reuse the same id, writing police in one source and metropolitan_police in another, and Stage 2’s rule deliberately left every uncertain pair apart. Resolution merges these into one node per real entity or event, and it is the stage where I most wanted a person in charge, because a wrong merge invents a fact: two people merged into one is a claim the text never makes.
So the work is split three ways:
- The build is deterministic. The same id across sources means one node, and on top of that a file of overrides lists merges, splits, renames and drops, of which the build applies only the entries marked
accepted. - An LLM proposes. A separate script finds candidate pairs (similar names, the same address, a shared event when one side is unnamed) and asks the model to judge each pair as
merge,separate,unsureor, for events, “this is a sub-event of that”. The model sees both sides’ descriptions and the paragraphs they cite, and it is told not to merge on suspicion, since whether an unnamed culprit is a named suspect is the detective’s job, not the resolver’s. Its verdicts land in the overrides file asproposed. - A person accepts or rejects. A review command prints each proposal together with what accepting all of them would cause, such as a chain of merges that ends up joining two things judged separate, or one person under several surnames.
Of about 180 pairs, I accepted 147 verdicts, rejected 5 and left 29 undecided. The rejections were the interesting ones: one merge rested on an inference (“this brother’s sister must be that Grace”) and, combined with another accepted merge, would have turned two different women into one person, while two more were cases of the same surname belonging to different women. I also made two splits by reading, where the extractor had used one id both for a woman who had died and for a living woman with the same surname, and another both for a cigar that was a clue and for a cigar quoted from a novel in the newspaper.
Resolution matters most for events. On the gold sources, exact ids alone recover only 27% of the event merges they should (F1 0.43), while the accepted proposals bring that to 55% (F1 0.71) with no false merges. The finished graph has 153 people, 47 organisations, 128 places, 159 objects and documents, 213 events and 1,152 claims, and once events are merged and dated they can be laid out in time, as Figure 8 shows.
Fig. 8. The timeline after resolution. The kidnapping’s sub-events (abduction, captivity, release) sit inside it because resolution confirmed they are part of it, dashed cards have approximate dates, and every card shows its derived status. The panel lists how each of the 14 sources that mention the kidnapping describes it, with the quotes behind them.
Where the Graph Lives
At the end of the pipeline, the knowledge model is stored in two quite different ways, one for the schema and one for its instances.
The ontology is not written in a standard ontology language such as OWL or RDF. It is a single Python module of Pydantic classes and fixed vocabularies (the entity types, relation kinds, event types, roles, voices and stances), together with the rule that derives a status from claims. I chose that over OWL because the ontology’s main job here is to be the LLM’s output schema and to validate what comes back, which Pydantic does directly. OWL’s strengths, such as formal reasoning over class hierarchies and vocabularies shared across organisations, are real, but nothing in a single detective case needed them.
The graph is two JSON files written by the resolution step: one of nodes, each shaped {id, label, name, props, evidence}, and one of edges, each shaped {source, type, target, props, evidence}. The claims behind a fact and its derived status sit in its props, and the evidence field lists the paragraph ids, so a single edge carries everything needed to judge it:
{ "source": "document:customs_house_papers", "type": "RELATED_TO", "target": "place:customs_house",
"props": { "kind": "located_at", "status": "observed",
"attestations": [ { "passages": ["19 EC#p6"], "mode": "narration", "stance": "asserts",
"asserted_by": null, "quote": "The man sits up and flicks through some papers" } ] },
"evidence": ["19 EC#p6"] }
The paragraph nodes carry their text as well, so these two files hold both the facts and the words they were read from. The build can also load the graph into Kùzu, an embedded graph database, with one table per node label and edge type, which is handy for ad hoc queries in Cypher. But at 2,786 nodes, every consumer in this project, the web app, the chatbot and the agent in Part 3, simply reads the two JSON files into memory, and nothing queries the database. What makes this a knowledge graph is the ontology behind it, not the database it happens to be stored in.
Who Does What
Putting the stages side by side:
| Stage | Done by | What goes wrong without a check |
|---|---|---|
| Digitise | Claude reads the photos | A misread word becomes a wrong fact everywhere downstream |
| Schema and gold set | A person, with Claude’s help on the gold set | The model fills whatever shape you give it, good or bad |
| Backbone | Code | Little, which is why it goes first and everything attaches to it |
| Extraction | LLM, checked by code | Invented quotes and ids that drift between sources |
| Resolution | Code, LLM proposals, a person | A wrong merge invents a fact the text never states |
The pattern is the same at every LLM stage: the model drafts, code checks the draft against the text, and a person makes the decisions that would create facts. None of it is fully automated, and I don’t think it should be. The LLM takes on the tedious part, reading every paragraph and filling in the schema, which would have cost me days. What it leaves to me is a much smaller set of decisions that carry real weight, such as whether two names belong to the same woman, and there were only a few dozen of those, each one shown to me with its evidence.
Part 2: A Chatbot on Top of the Model
The web app has a chat panel that answers questions about the case in plain English, citing the paragraphs it relies on. I designed the model’s interaction with the graph in two modes from the start. In Ask, the model reads the text of the case, while the graph decides which names it may use and which paragraphs it may cite, and then checks everything it returns. In Deduce, which sets out to solve the case, the graph’s own facts enter the prompt as well. To make this concrete, I follow one real question through Ask, “What do we know about the ransom note?”, asked with every clue in the case available, and then show what Deduce adds.
What the Model Is Given
There is no retrieval step. The whole case is about 35,000 tokens, which fits comfortably in one prompt, so every question sends all of it, at the cost of one API call per question. Figure 9 shows what that prompt is made of.
Fig. 9. The prompt for one question, drawn to scale, and what happens to the answer. Ask sends the rules, the entity list and every paragraph; Deduce adds a digest of the graph on top. The token counts for the parts are estimated from their share of the characters, and the total is the one the API reported.
The prompt has four parts, in this order:
The rules, about 300 tokens, which set the job and the format of the answer:
You help players of a detective board game think about one case. Answer the question using ONLY the passages below: what the characters say, what the narrator observes, and what the newspaper prints. Each passage starts with its id in square brackets. - Cite every statement: put the ids of the passages that support a paragraph in its `citations`, the one to three most direct ones, not every passage that touches the topic. Cite only ids that appear below. - Keep who-said-what visible. "Sir Colin says...", "The Times reports...". Testimony can be wrong; do not turn a claim into a fact, and point out where sources disagree. - Do not solve the case or guess beyond the text. If the passages don't answer the question, say so plainly, and say what kind of lead might. - Mark people, organisations, places, objects, documents and events from the entity list inline as [[entity_id|the words you use]], e.g. [[person:sir_colin_pickwick|Sir Colin]]. Use only ids from the list. - Be brief: one to four short paragraphs, plain English. - In `sources`, give each cited passage once, with a short fragment copied exactly from it.The entity list, one line for each of the 697 people, organisations, places, objects, documents and events that appear in the text, with its id, its name and a few of its aliases. This is where the graph first shows up, and it takes almost 40% of the prompt. Three of its lines:
person:hr_murray | H.R. Murray | also: Mr Murray, Murray person:kenneth_train | Kenneth Train | also: Mr Train, Kenneth, Kenneth Duncan Train place:new_putney_bridge | the new Putney bridge | also: Putney bridge, the Putney bridge- Every paragraph of the case, 389 of them from 76 sources, grouped by source, each line starting with its paragraph id in the same form the extractor saw in Stage 4:
[63 NW#p1] An old man with a monocle.... - The conversation so far, at most the last four questions and answers, followed by the question itself.
The prompt deliberately carries little of the graph’s content: no relations, no claims and no statuses, only the names of things and the paragraph text, which itself lives in the graph’s paragraph nodes. Ask’s job is to report what the sources say, and the paragraphs are the most faithful form of that, whereas the extracted facts are an interpretation of them that can carry mistakes, such as the misplaced denial from Stage 4. The entity list is therefore not there to inform the answer. It is a vocabulary that tells the model which ids exist, so that every name in the answer can be tied to a node, and so that the server can tell a real id from an invented one.
What Comes Back, and What the Server Checks
The model answers in a structured format: a list of paragraphs, each with its text and the paragraph ids it cites, a list of sources, each with a short quote copied from a cited paragraph, and up to three follow-up questions. Here is the first paragraph exactly as gpt-6.2-sol returned it on 28 November 2026, from a prompt of 34,722 tokens and an answer of 531:
{ "text": "The [[document:ransom_note_for_wendy_sturton|ransom note for Wendy Sturton]] demanded [[object:sturton_ransom_money|£2,000 in a sack]], to be left on the north bank under the [[place:new_putney_bridge|new Putney Bridge]] at dawn the next day, in exchange for her safe return. [[person:kenneth_train|Kenneth Train]] says it was found under a rock on his doorstep at 5 p.m. on 16 November. He says no one was seen leaving it.",
"citations": ["22 SW#p9", "61 NW#p2", "61 NW#p6"] }
The rules are visible in the result. Each statement is attributed (“Kenneth Train says”), and the second paragraph of the answer compares this note with the one from an earlier kidnapping, then stops short of a conclusion: the similarities “don’t establish who wrote or delivered either note”. That is the “do not solve the case” rule at work.
Before the answer reaches the screen, the server checks it against the graph, item by item:
- every
[[id|words]]must be an id from the entity list; if it is not, the words stay but the link is removed; - every citation must be a paragraph id the model was given; if it is not, the citation is dropped;
- every quote must occur in the paragraph it claims to come from; if it does not, the opening of the paragraph is shown instead.
On this question the checks had nothing to do: all 8 entity marks were real ids, and all 6 citations and 5 quotes held up. That is the outcome you hope for, but the checks cost nothing to run, and they mean that whatever the model writes, the reader can never be sent to a paragraph or a node that does not exist.
Fig. 10. The checked answer in the app. Each underlined name is a link to its node, coloured by entity type, and the graph on the left highlights the eight entities the answer mentions. The numbers after each paragraph point to the sources listed below the answer, each a paragraph the reader can open.
So in Ask, the graph is an index and a guard rather than a source of knowledge. The model reasons from the text; the graph tells it what it may name and cite, and then holds it to that.
Deduce: When the Graph’s Own Facts Enter the Prompt
Ask is told not to solve the case. Deduce is the mode that is told to: it swaps the rules for a method (put every dated event in order, list what the text says about each unknown actor, decide which nodes are the same person, follow the physical clues, and keep what a source states apart from what is inferred), and it adds a graph digest of about 15,000 tokens on top of everything Ask sends. This is the point where the graph’s own facts enter the prompt:
- Every event, all 213 of them, with its status and one description from each source that mentions it, merged across sources by the resolution step. A single line can bring together what the introduction and a later lead each say about the abduction, with the status those accounts add up to.
- Every claim about an unknown actor, grouped by actor: the two kidnapping gangs and two unnamed men, each with the paragraphs behind the claim.
- The merge proposals still awaiting review, the pairs from Stage 5 that an LLM judged to be the same entity but that nobody has accepted yet, offered as hypotheses to test. After my review in Stage 5, no pair with a “merge” verdict is left waiting, so in the current graph this section is empty.
The answer comes back in a fixed shape: the conclusion with a confidence, then the chain of evidence one step at a time, each step labelled Stated (a source says it) or Inferred (the model’s reasoning), and finally the strongest point against the conclusion. The same checks as in Ask apply to its names, citations and quotes. A question costs about 50,000 tokens, and whether the digest actually helps the model reach the right answer, and whether a model should instead explore the graph step by step, is the subject of Part 3.
The practical consequence for anyone putting a chatbot on top of a knowledge graph: decide what the graph is for in each prompt. As a vocabulary and a set of checks, it makes answers traceable at almost no cost. As content, it can hand the model work it would otherwise have to redo, such as a timeline already merged across sources, but only if you choose which parts of it the model sees.
Part 3: How Should a Model Consume the Graph?
Deduce hands the model everything at once. The common alternative, and the one most agent frameworks are built around, is to give the model a small index and a set of tools, and let it fetch only what it needs. Both are reasonable ways to consume a knowledge graph, so I built both and ran them on the case’s first question, “Who kidnapped Wendy Sturton?”, with three models.
Two Designs
- One call. This is Deduce from Part 2: every paragraph plus the graph digest, about 48,000 tokens, sent in a single call that returns the answer.
- Step by step. An agent starts with only an index of entity ids and names, about 6,000 tokens, and queries the graph through six tools:
findlooks up entities by name or description,factsreturns every claim about an entity with its paragraph ids,timelinelists events in date order,pathsfinds how two entities are connected,readreturns the text of given paragraphs, andfinal_answerends the run. Each tool takes a list, so one call can fetch many things, and calls made in the same turn run in parallel. The agent has at most 8 turns and must answer on the last one.
The cost of the second design is easiest to see in a real run. Here is a trial run with gpt-6-luna, outside the benchmark, turn by turn:
| Turn | What the agent did | Prompt tokens that turn |
|---|---|---|
| 1 | find with 8 queries: the kidnappers, the ransom note, the scarf, the money | 7,146 |
| 2 | facts on 8 ids: the kidnapping, its sub-events, the note, the scarf | 10,316 |
| 3 | facts on the unknown actors and the other kidnapping | 17,933 |
| 4 | read on 6 paragraphs, and facts on the ropes and scarves | 24,106 |
| 5 | final_answer: “an unidentified gang” | 26,301 |
The prompt grows with every turn because each turn re-sends the instructions, the index and every earlier result, so five modest turns add up to more than 85,000 input tokens, much of it cached. That is not a flaw in this agent; it is how a tool-calling loop works, and it is the price of letting the model choose what to read.
How the Answers Were Scored
To score an answer, I wrote a reference answer from the official solution and split it into a rubric worth 9 points over six items: naming the two people who organised the kidnapping (3 points), recognising that two names in the graph belong to the same person (1), connecting the timing of one person’s daily routine to the moment of the kidnapping (2), explaining what the ransom note was really for (1), identifying the accomplice and their part (1), and citing only paragraphs that exist (1). Code checks the names, the identity and the citations; gpt-6.2-sol, acting as a judge, checks the other three against the answer and the paragraphs it cites. Each of the 6 combinations of design and model ran 3 times, 18 runs in all on 27 November 2026, and the whole benchmark, judging included, cost $3.53.
One Call Wins, Here
Figure 11 shows the result.
Fig. 11. Score out of 9, the mean of three runs per bar, with the cost per question. One call on gpt-6.2-sol scored 9 on every run at 7 cents. The step-by-step agent scored lower on both capable models and cost three times as much or more; on gpt-5.5 its three runs scored 8, 7 and 2.
The full numbers, per run:
| Design | Model | Score /9 | Input tokens (cached) | LLM calls | Seconds | $ per question |
|---|---|---|---|---|---|---|
| One call | gpt-6-luna | 1.0 | 48k (32k) | 1 | 28 | 0.004 |
| One call | gpt-6.2-sol | 9.0 | 48k (32k) | 1 | 50 | 0.073 |
| One call | gpt-5.5 | 9.0 | 48k (32k) | 1 | 76 | 0.289 |
| Step by step | gpt-6-luna | 1.0 | 181k (142k) | 6.7 | 51 | 0.007 |
| Step by step | gpt-6.2-sol | 7.0 | 224k (131k) | 8 | 60 | 0.224 |
| Step by step | gpt-5.5 | 5.7 | 262k (208k) | 8 | 78 | 0.514 |
The cheapest configuration that solves the case is one call on gpt-6.2-sol, at about 7 cents a question, and it is now what the app’s Deduce mode uses. gpt-5.5 matches its score at four times the price. gpt-6-luna fails in both designs, settling for “an unidentified gang” in one, and accusing the wrong person in the other, so its low price buys nothing.
The step-by-step agent lost on both quality and cost, and the reasons are specific:
- It read more and saw less. It used 4.6 to 5.4 times the input tokens of one call, because of the growing prompt shown above.
- It missed the clue that needs two facts side by side. On gpt-6.2-sol it never connected the timing of the routine to the kidnapping, in any of its three runs. It fetched the right event and read the right paragraph, but the two halves of the clue arrived in different tool results, several turns apart, and it never put them together.
- It ran out of time. Both capable models used all 8 turns on every run, so they were still gathering evidence when they were made to answer, and gpt-5.5’s three runs scored 8, 7 and 2.
- Its evidence was cut. 24 of its 158 tool results hit the size cap of 14,000 characters, because asking for the facts about six entities at once returns too much, so the model reasoned from truncated evidence.
The reason one call wins here is simple. The whole case, about 35,000 tokens of text plus the digest, fits in one prompt, and the decisive clue in this case is a comparison between two facts from different sources. With everything in view, and the events already merged and ordered by the resolution step, the model can line them up. The agent has to know in advance that it needs both facts, fetch them both, and then compare them across a long and growing transcript.
If the knowledge fits in the prompt, give the model all of it, organised. Let it query only what does not fit.
Step by step would earn its place in two situations this case does not have: a graph too large for any prompt, and a need for an auditable record of exactly what the model looked at. If I needed it here, I would start with four changes: return the facts in a compact form so nothing is cut, put the timeline digest in the first turn instead of the full index, allow more turns, and add a tool that lays out a person’s routine and the events of a day in one table. That is also the point at which the graph database from Part 1 would come in, as the engine behind those tools once the graph no longer fits in memory.
Closing Thought
The throughline is that the ontology is the decision, and everything else is filling it and reading it. The schema decided what the LLM could extract, what the checks could verify, what a status means, and what a chatbot could name and cite; every later stage only worked because that shape was settled first.
Three lessons recur across the build:
- Keep the schema and the graph apart. The ontology is a small, deliberate description of the world you care about, and here it doubles as the LLM’s output schema; the graph is its instances, large and mostly produced by a pipeline.
- Build facts from claims. When every fact records who said it and in what voice, status can be derived instead of guessed, contradictions surface by themselves, and every answer can be traced to a paragraph.
- Let the LLM draft, code check and a person decide. The pipeline is not fully automated, and the parts left to a person are the few decisions that would create facts.
And once the graph exists, how a model consumes it matters as much as what is in it. As a vocabulary and a set of checks, the graph keeps a chatbot honest at almost no cost; as content, organised into a digest, it let a single call solve a case that an agent with tools could not. Holmes’s mind palace works not because it holds every fact, but because every fact has its place and he knows who put it there.