<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Prashant Krishan Bharti</title>
    <description>The latest articles on DEV Community by Prashant Krishan Bharti (@prashant_krishanbharti_e).</description>
    <link>https://dev.to/prashant_krishanbharti_e</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4284763%2Fc42e1d26-3857-4902-92ee-bc49635963e9.png</url>
      <title>DEV Community: Prashant Krishan Bharti</title>
      <link>https://dev.to/prashant_krishanbharti_e</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prashant_krishanbharti_e"/>
    <language>en</language>
    <item>
      <title>An agent that checks its own answers: GraphRAG on TigerGraph for messy, conflicting evidence</title>
      <dc:creator>Prashant Krishan Bharti</dc:creator>
      <pubDate>Sat, 05 Dec 2026 13:07:22 +0000</pubDate>
      <link>https://dev.to/prashant_krishanbharti_e/an-agent-that-checks-its-own-answers-graphrag-on-tigergraph-for-messy-conflicting-evidence-1pk</link>
      <guid>https://dev.to/prashant_krishanbharti_e/an-agent-that-checks-its-own-answers-graphrag-on-tigergraph-for-messy-conflicting-evidence-1pk</guid>
      <description>&lt;p&gt;&lt;em&gt;Our Round 2 entry for the TigerGraph Agentic GraphRAG Hackathon&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code:&lt;/strong&gt; &lt;a href="https://github.com/Kultzuki/TigerGraphV2" rel="noopener noreferrer"&gt;github.com/Kultzuki/TigerGraphV2&lt;/a&gt; ·&lt;br&gt;
&lt;strong&gt;Live demo:&lt;/strong&gt; &lt;a href="https://kultzuki.github.io/TigerGraphV2/" rel="noopener noreferrer"&gt;kultzuki.github.io/TigerGraphV2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Round 1 of the hackathon asked for one-field lookups. Round 2 is harder, and closer to real data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Answers need several documents.&lt;/li&gt;
&lt;li&gt;Some sources disagree.&lt;/li&gt;
&lt;li&gt;Some facts change over time.&lt;/li&gt;
&lt;li&gt;Some questions have no answer in the corpus at all.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An invented answer scores zero.&lt;/p&gt;

&lt;p&gt;This post explains how we built a system that handles that, what worked, and what didn't.&lt;/p&gt;
&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;The corpus has 3,530 documents:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Olympic event articles from 1988 to 2026.&lt;/li&gt;
&lt;li&gt;Films and officeholders.&lt;/li&gt;
&lt;li&gt;166 fictional articles about the "LA 2028" Games, including 39 short source records: scoreboard
captures, jury decisions, schedules, bulletins, news items, blog posts and emails.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each LA 2028 source record states who published it and when. Like real sources, some are&lt;br&gt;
provisional, some are out of date and some are simply wrong, and none of them says so about itself.&lt;/p&gt;

&lt;p&gt;A typical hard question: &lt;em&gt;who won the bronze in the LA 2028 men's 100 metres?&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A provisional scoreboard capture&lt;/strong&gt; at 21:07 shows one athlete in third place.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A signed photo-finish jury decision&lt;/strong&gt;, effective at 22:15 the same evening, gives the bronze to
someone else.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A spectator blog the next day&lt;/strong&gt; repeats the provisional order.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A good answer gives the official result, says when it took effect, and explains why the other two&lt;br&gt;
documents differ. Picking the most recent document gives the wrong answer here, and so does&lt;br&gt;
picking the most frequent one.&lt;/p&gt;
&lt;h2&gt;
  
  
  Our approach: let the model plan, let code decide what is true
&lt;/h2&gt;

&lt;p&gt;Language models are good at deciding what to look up. They are less reliable at stating exact&lt;br&gt;
values, keeping lists complete, and admitting that something is missing. So we split the work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The model&lt;/strong&gt; plans the lookups and proposes an answer. Each fact it proposes must point at the
graph rows that support it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code&lt;/strong&gt; checks every proposed fact against those rows. It re-runs every calculation and writes
the final answer, explanation and citations itself, from the facts that pass.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The model never gets the last word on a value.&lt;/p&gt;
&lt;h3&gt;
  
  
  How documents become graph data
&lt;/h3&gt;

&lt;p&gt;The graph runs on TigerGraph 4.2.6 Community Edition in Docker. After loading it holds 133,555&lt;br&gt;
vertices and 298,665 edges, and every relationship is verified by reading it back after the build.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Event articles&lt;/strong&gt; are parsed by code. Infobox podiums (including shared bronzes and vacated
medals), participation counts, venues and dates become &lt;code&gt;Event&lt;/code&gt;, &lt;code&gt;EventSeries&lt;/code&gt;, &lt;code&gt;GamesEdition&lt;/code&gt;,
&lt;code&gt;MedalAward&lt;/code&gt;, &lt;code&gt;Person&lt;/code&gt; and &lt;code&gt;NOC&lt;/code&gt; vertices.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Films and officeholders&lt;/strong&gt; become credits, money ranges and office terms, with predecessor and
successor links.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The 39 LA 2028 source records&lt;/strong&gt; go through one LLM call each, at build time only. The call
extracts atomic claims with an exact quote, a source class, a modality (provisional, final,
unverified and so on) and publication, observation and effective times.

&lt;ul&gt;
&lt;li&gt;A second pass links claims that supersede, repeat, corroborate or contradict each other.&lt;/li&gt;
&lt;li&gt;The result is 146 &lt;code&gt;EvidenceClaim&lt;/code&gt; vertices, a small bi-temporal claim ledger.&lt;/li&gt;
&lt;li&gt;The extractions are cached in the repo, so rebuilding the graph needs no model call.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Every document&lt;/strong&gt; is split into 18,971 passages. Passages are linked to the people, films and
events they mention, and each one carries a 512-dimension embedding in TigerGraph's native HNSW
vector index.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  The tools
&lt;/h3&gt;

&lt;p&gt;The agent has nine tools that query TigerGraph through 18 installed GSQL queries:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;five structured tools: events, medals, athlete results, films and office succession;&lt;/li&gt;
&lt;li&gt;a hybrid search that combines HNSW vector seeds and lexical seeds with Personalized PageRank over
the mention graph, then reranks with a cross-encoder;&lt;/li&gt;
&lt;li&gt;the claim ledger, a table inspector and a passage reader.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two more tools don't query the graph: one sets a time policy ("what was known by 2 July?"), and&lt;br&gt;
&lt;code&gt;submit_answer&lt;/code&gt; is the only way to finish.&lt;/p&gt;
&lt;h3&gt;
  
  
  How a question is answered
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;First turn.&lt;/strong&gt; The model calls a tool and declares what the question asks for, as a short list.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fast path.&lt;/strong&gt; If one structured tool's computed outputs cover every part of the question, code
computes the answer (counts, extremes with ties, trends, lists).

&lt;ul&gt;
&lt;li&gt;A short independent review then has to name, for each part of the question, the output field
that answers it, and code checks that the field exists.&lt;/li&gt;
&lt;li&gt;So a list of names can no longer "answer" a question about a score or a reason.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Composer.&lt;/strong&gt; Otherwise, one model call writes the answer from the rows already fetched. It runs
without the tool definitions and without the conversation history, which keeps it cheap.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent loop.&lt;/strong&gt; If the composer can't establish every part of the answer, the agent continues
with more searches: passages, tables, the claim ledger, or a corpus-wide search before it may
say &lt;code&gt;not_in_corpus&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validation.&lt;/strong&gt; Every submitted fact is checked against the rows it cites:

&lt;ul&gt;
&lt;li&gt;every number, name and content word must appear in the support;&lt;/li&gt;
&lt;li&gt;a number must be stated about the same subject, which catches values swapped between two
athletes;&lt;/li&gt;
&lt;li&gt;code re-runs any computation, including differences between race times like "1:45:01".&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Rejected facts go back to the model with the reasons attached.&lt;/p&gt;

&lt;p&gt;The status follows from the facts that pass: all established is &lt;code&gt;answered&lt;/code&gt;, some is &lt;code&gt;partial&lt;/code&gt;,&lt;br&gt;
none is &lt;code&gt;not_in_corpus&lt;/code&gt;. Qualifiers the evidence states are kept next to the fact they qualify:&lt;br&gt;
when a decision took effect, what was provisional, what remains unverified.&lt;/p&gt;
&lt;h3&gt;
  
  
  Conflicting and dated sources
&lt;/h3&gt;

&lt;p&gt;The claim ledger resolves conflicts with five general rules:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Source authority:&lt;/strong&gt; an official decision outranks an official record, which outranks a
schedule, then a provisional display, then secondary media, then informal posts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Valid time:&lt;/strong&gt; a claim applies only inside its validity window.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supersession:&lt;/strong&gt; a later source of equal or higher authority retires the claim it replaces.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stale repetition:&lt;/strong&gt; a low-authority source that repeats superseded data adds no support.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grouping:&lt;/strong&gt; claims are resolved per topic and per event, so two different events never get
merged into one conflict.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The time policy hides every source not yet published, or not yet in force, at the asked instant.&lt;br&gt;
A notice published before that instant that takes effect later is reported as an announced change,&lt;br&gt;
not as the current value.&lt;/p&gt;

&lt;p&gt;Every answer line carries its citations, token counts, latency and a full trace. Each TigerGraph&lt;br&gt;
step in the trace matches an entry in the request log one to one.&lt;/p&gt;
&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;All three pipelines use the same model, DeepSeek V4.1 Flash 1017 on Baseten with reasoning off, the&lt;br&gt;
same graph and the same judge. Accuracy is fact-level F1 against the published answers, graded by an&lt;br&gt;
independent model (Gemini 4 Neon) rather than by the model that produced the answers.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pipeline (public 50 questions)&lt;/th&gt;
&lt;th&gt;Accuracy&lt;/th&gt;
&lt;th&gt;Status correct&lt;/th&gt;
&lt;th&gt;Tokens per question&lt;/th&gt;
&lt;th&gt;Latency p50 / p95&lt;/th&gt;
&lt;th&gt;Cost for 50&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;RAG: TigerGraph vector search, one LLM call&lt;/td&gt;
&lt;td&gt;57.4%&lt;/td&gt;
&lt;td&gt;25 / 50&lt;/td&gt;
&lt;td&gt;2,217&lt;/td&gt;
&lt;td&gt;0.8 / 1.7 s&lt;/td&gt;
&lt;td&gt;$0.08&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GraphRAG: vector + lexical seeds + PageRank + reranking, one LLM call&lt;/td&gt;
&lt;td&gt;70.7%&lt;/td&gt;
&lt;td&gt;33 / 50&lt;/td&gt;
&lt;td&gt;2,699&lt;/td&gt;
&lt;td&gt;1.9 / 3.0 s&lt;/td&gt;
&lt;td&gt;$0.10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Agentic GraphRAG&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;95.2%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;48 / 50&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;16,185&lt;/td&gt;
&lt;td&gt;2.3 / 5.8 s&lt;/td&gt;
&lt;td&gt;$0.22&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The graph adds 13 points over plain vector RAG. The agent adds another 24: structured graph tools,&lt;br&gt;
the claim ledger, the time policy and per-fact validation. A second run of the public set scored&lt;br&gt;
95.3%, with the same answer status on all 50 questions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Public questions flatter everyone,&lt;/strong&gt; because that's the set you test against while building.&lt;br&gt;
So we wrote our own dev set: 120 questions, 65 of them new and written from corpus documents,&lt;br&gt;
including trap questions and LA 2028 source scenarios.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Every fact is backed by a quote.&lt;/strong&gt; Code checks that the quote appears verbatim in the document.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No overlap with the public set.&lt;/strong&gt; No new question shares a six-word phrase with a public
question.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A held-out set.&lt;/strong&gt; 40 of the new questions are only run at checkpoints.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On those 40 unseen questions the final system scores 92.6%, against 82.9% for our previous version&lt;br&gt;
on the same provider and judge. Latency also dropped: p95 went from 11.8 s to 5.8 s.&lt;/p&gt;
&lt;h2&gt;
  
  
  What didn't work
&lt;/h2&gt;

&lt;p&gt;Not every idea held up once we measured it. Three that didn't:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Letting the composer settle every answer.&lt;/strong&gt; It halved tokens per question, but the system
started giving up too early. The first search often finds the right article but not the right
sentence. Now the composer only finishes fully established answers, and everything else goes
back to the agent loop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extra repair rounds.&lt;/strong&gt; We tried a targeted search turn followed by another composition after a
failed answer. It used 5% more tokens and gained no accuracy, so it's switched off.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cutting agent turns.&lt;/strong&gt; The questions that take four or five turns are also our most accurate
ones. Limiting turns would save tokens by giving up exactly those answers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tokens per question are still higher than we'd like. Most of them go to the careful multi-turn&lt;br&gt;
questions, and that's a trade we chose on purpose.&lt;/p&gt;
&lt;h2&gt;
  
  
  Things we'd recommend to anyone building one of these
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Have code own the facts.&lt;/strong&gt; A validator that checks each value against its cited rows prevents
more errors than any prompt instruction we tried.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Store claims, not just documents.&lt;/strong&gt; When sources disagree, you need publication time, validity
time, authority and supersession as data, not as text the model has to reread every time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grade with a different model,&lt;/strong&gt; and keep a held-out set that you never tune against. Our
public score and our held-out score sometimes moved in opposite directions. The held-out one was
the honest signal.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replay before you refactor.&lt;/strong&gt; We recorded the model's responses and replayed them through
refactored code. That turns "no behaviour change" from a hope into a check: in our case, 97
recorded responses, zero mismatches.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;The repo builds and runs with three commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./build.sh corpus.jsonl
./run.sh questions_public.jsonl answers_public.jsonl
./serve.sh   &lt;span class="c"&gt;# the web app, with the live agent answering new questions&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://kultzuki.github.io/TigerGraphV2/" rel="noopener noreferrer"&gt;live demo&lt;/a&gt; replays the public run with full traces,&lt;br&gt;
per-fact validation, the pipeline comparison, and the LA 2028 claim ledger, which you can scrub&lt;br&gt;
through time.&lt;/p&gt;

&lt;p&gt;Built for the TigerGraph Agentic GraphRAG Hackathon, Round 2. #GraphRAG #TigerGraph #LLM #RAG&lt;/p&gt;

</description>
      <category>ai</category>
      <category>hackathon</category>
      <category>llm</category>
      <category>rag</category>
    </item>
  </channel>
</rss>
