Graphiti: where the dated graph helps and where it fails

Hand-written, from the recorded model calls of the Graphiti run in results/main/graphiti/ (one episode per message), read next to the LongMemEval histories and the source of graphiti-core 0.31.1. Every call the library made was logged with its prompt and reply: the entities and facts extracted from each message, with their dates, and every decision on whether a new fact duplicates or contradicts an existing one. So for each question one can follow the revised fact from the message that states it, through extraction and resolution, into the graph and into the ten facts retrieved at question time.

67 questions are too few to estimate rates; the counts describe this run, and the mechanisms are the result.

Summary

Graphiti answers 55 of 67 (82%, 95% interval 71–89%), in the same band as Mem0 and Honcho's dialectic chat, at 720 model calls and $0.64 per question, by far the most expensive arm. When its design works it works well: in the 26 questions where the new fact reached the answer and the old one reached it marked [superseded], the answer was right every time. The 12 failures come from four places:

  1. The revision was never extracted (6). The extraction prompt keeps the subject of a message and drops asides: "brings my total species count to 32" produced facts about sunflower seeds, suet and the Northern Flicker but no count; "like we do every other week" became "planning to play tennis… this coming Sunday". With no fact carrying the new value there was nothing to supersede the old one.
  2. The revision was extracted in a form that does not contradict the old fact (1). "Head to the gym, which is usually at 6:00 pm" became "a gym commitment at 6:00 pm on Tuesday", next to the unchanged Monday/Wednesday/Friday 7 pm.
  3. The resolution went wrong (2). Once because of how dates work: a fact is dated by when it became true, which for "a recent family trip to Hawaii" is the day it was mentioned and for Paris ("we just went there as a family last month") is a month earlier, so Graphiti closed Paris as superseded by Hawaii. Once because the old value was stored twice and only one copy was closed.
  4. Both values were delivered and the answer still went wrong (3): it computed a duration from the wrong fact, added planned titles to a count, and declined to give a number.
Cause answers questions
Revision never extracted as a fact carrying the new value 6 5c40ec5b, a2f3aa27, affe2881, c4ea545c, c6853660, f685340e
Revision extracted in a form that does not contradict the old fact 1 59524333
Resolution: the date logic closed the new fact instead of the old 1 9ea5eabc
Resolution: the old value was stored twice, one copy closed 1 945e3d21
Revision delivered; the answer computed, added or hedged wrongly 3 2133c1b5, 4d6b87c8, 7401057b

What reached the answer, for every question:

What the ten retrieved facts held questions correct
the new fact, and the old one marked [superseded] 26 26
the new fact, and the old one still current 13 10
the new fact, and no old one 12 10
the new fact only as a closed edge 1 0
no fact with the new value 4 0
(questions about an earlier value, or both values) 11 9
total 67 55

How Graphiti ran here

Where the 720 calls per question go:

Step calls per question
Does this new fact duplicate or contradict existing ones? 25,122 375
Extract entities from the message 7,980 119
Extract facts from the message 7,974 119
Resolve entities against existing ones 5,451 81
Summarise entities 1,675 25
Extract dates for a fact 43 0.6

Most of that work is spent on the assistant's text. Assistant messages produced 17,211 of the 22,702 facts extracted (76%), 4.8 per message against 1.5 per user message: "The assistant recommends using hand soap to clean black Converse", "The Hilton Lake Las Vegas Resort typically requires approximately 40,000 points for a standard room reward night". Each of those facts then gets its own contradiction check. Of the 670 facts retrieved over all questions, 133 are about the assistant or its advice and 127 are general facts with no user in them; 410 are about the user.

1. Extraction: a revision mentioned in passing becomes no fact

The fact-extraction prompt asks for "fact triples" between the entities found in the current message and tells the model to preserve "quantities, counts… specific items". The entity prompt, which runs first, says "When in doubt, do not extract the entity" and tells the model to never extract "Generic event/activity nouns", "Abstract concepts", "Bare generic objects". In practice the model extracts what the message is about and lets the aside go:

Question the revision, as said facts extracted from that message
affe2881 "…I just saw a Northern Flicker in my local park last weekend, which brings my total species count to 32." "plans to bring sunflower seeds to the park to attract woodpeckers"; "plans to bring suet…"; "The Northern Flicker is a species of woodpecker"; "observed a Northern Flicker in their local park last weekend"
a2f3aa27 "…I've been meaning to check my current follower count - I think I'm close to 1300 now." "is actively creating content for their Instagram account"; "has a target audience based in the US" (and the UK, and Australia)
5c40ec5b "…I've got a friend Alex from there who I met at a music festival, and we've met up twice already…" "is friends with Alex, whom they met at a music festival"; "Alex is from Germany"; "met their friend Alex at a music festival"
f685340e "…I'm planning to play tennis with my friends at the local park this Sunday, like we do every other week." "is planning to play tennis with the user's friends at the local park this coming Sunday"; "will play tennis at the local park with friends this Sunday"
c4ea545c "…since I've been consistent with my gym routine - four times a week, actually." "plans to meal prep healthy dinner recipes on Sunday"; "plans to have a post-workout smoothie on Saturday as a reward for consistent gym attendance"
c6853660 "…I'm thinking of changing my morning coffee limit to two cups…" and later "…I have increased the limit to two cups…" "is currently using a drip coffee maker"; then "is excited to try out the French press method", "intends to use a darker roast with the French press method", two facts about stevia and honey

In each case the earlier value had been extracted cleanly, because there it was the point of a sentence: "The user has spotted 27 different bird species in their local park", "The user has 1250 followers on Instagram", "The user plays tennis with friends on a weekly basis", "The user goes to the gym on Tuesdays, Thursdays, and Saturdays", "The user consumes one cup of dark roast coffee in the morning". These stay current, and they are what the search retrieves.

The extraction is not careless in general: in 78% of questions the probe finds the new value somewhere in the graph. It fails on a specific shape, a quantity or frequency stated as an aside to a request about something else, or as a plan ("thinking of changing… to two cups").

2. Resolution: when a new fact closes an old one

For each new fact, Graphiti retrieves two lists: facts between the same two entities ("EXISTING FACTS") and similar facts anywhere ("FACT INVALIDATION CANDIDATES"), and asks the model which of them the new fact duplicates and which it contradicts. The prompt is deliberately conservative:

NEVER mark facts as contradicted unless the new fact explicitly makes the old fact false. … A contradiction requires explicit evidence that the old fact stopped being true or was replaced… Do NOT infer contradiction from recency alone, episode dates…

Over the run, 301 of the 25,122 decisions (1.2%) marked any contradiction, and 1,264 marked a duplicate. The graph closed 4.8 facts per question out of about 319.

When the model does mark a contradiction, Graphiti still decides which fact to close from the dates, not from the order the facts arrived in (resolve_extracted_edge and resolve_edge_contradictions in graphiti_core/utils/maintenance/edge_operations.py):

valid_at comes from the extraction prompt's rule: "If the fact is ongoing (present tense), set valid_at to the timestamp of the episode", while relative phrases are resolved ("last month" → the first of last month). Of the 5,491 facts extracted from user messages, 5,267 got the message's own day, 183 an earlier date resolved from the text, and 24 a later one. This mostly works, and it is what makes the newer value win when both reach the answer. It fails when the two values are dated on different principles, as in 9ea5eabc.

3. Retrieval and the answer

The search returns ten facts. In this run the new value, when it existed in the graph, was usually among them; the failures are rarely retrieval. What retrieval adds is noise: a fifth of the facts shown are the assistant's suggestions, and those can carry the answer by accident. In dad224aa the only fact with 7:30 was "The assistant suggests starting a jog at 8:15-8:30 am to allow time to wake up at 7:30 am and have a cup of coffee beforehand"; the answer reasoned from it to the right time. In 618f13b2, the question whose key is the earlier statement, seven of the ten facts were the assistant's cleaning tips and the only count retrieved was "wore their new black Converse six times" (the later "four" was not), so Graphiti is the one arm that matches the key.

When both values reach the answer with their validity windows, the answering model follows the dates: 37 of the 39 questions where the probe found both delivered were answered correctly.

Every wrong answer

Positions are the user's message number within the session. "Other arms" are the seven other arms of the main run; "first run" is graphiti-chunk, where sessions were cut into 8,000-character episodes.

Revision never extracted

affe2881 — "How many different species of birds have I seen in my local park?" (32)

a2f3aa27 — "How many followers do I have on Instagram now?" (1300)

5c40ec5b — "How many times have I met up with Alex from Germany?" (twice)

c4ea545c — "Do I go to the gym more frequently than I did previously?" (yes)

c6853660 — "Did I mostly recently increase or decrease the limit on the number of cups of coffee in the morning?" (increased, one to two)

f685340e — "How often do I play tennis with my friends at the local park previously? How often do I play now?" (weekly, now every other week)

Revision extracted in a form that does not contradict

59524333 — "What time do I usually go to the gym?" (6:00 pm)

Resolution went wrong

9ea5eabc — "Where did I go on my most recent family trip?" (Paris)

945e3d21 — "How often do I attend yoga classes to help with my anxiety?" (three times a week)

Delivered; the answer went wrong

2133c1b5 — "How long have I been living in my current apartment in Harajuku?" (3 months)

4d6b87c8 — "How many titles are currently on my to-watch list?" (25)

7401057b — "How many free night's stays can I redeem at any Hilton property with my accumulated points?" (two)

How the correct answers were reached

The 55 correct answers by what the answer was given:

First run against the re-run

first run (8,000-character episodes) → re-run (one message per episode) questions
correct → correct 11
wrong → correct 44
correct → wrong 1
wrong → wrong 11

The one loss, 5c40ec5b, is the case above: the long episode kept "met… twice before" in one fact, the single-message episode dropped the count. The eleven wrong both times include all six revisions that were never extracted in the re-run: what the long episodes lost in general, the short ones still lose for asides.

What would change the outcome

What the logs support:

Limits

Contents

Reading

Text size

19 px

Column width

Colours

Code cells

When the file changes

Saved on this device.