When a deploy breaks production, the usual guess is the latest commit. This root cause agent tutorial builds a safer habit into an agent on FalkorDB. No change gets blamed unless a graph path connects it to every symptom. Graph Hacks, FalkorDB's online hackathon in October 2026, drew 7,899 developers and 1,213 projects, and two of them built this rule. On 28 failure scenarios the Kaizen team wrote from its own demo app, its graph ranked the right commit first 89% of the time. Blaming the latest commit managed 32%.
What is a root cause agent?
A root cause agent is an AI agent that takes a production alert and names the change that caused it, with evidence a person can re-run.
FalkorDB fits because the evidence is a path, and a path check is one Cypher query. GRAPH.RO_QUERY makes the database refuse writes from the agent. GRAPH.COPY gives it a throwaway copy to rehearse a fix on. And one instance holds many isolated graphs, so each repository or session can have its own.
Where does this root cause agent tutorial get its pattern?
Two Graph Hacks projects. The code below was written for this tutorial and is a small version of their rule.
Incident Commander · Nihesh Rachakonda · See the code · Use the app · Blog
It rebuilds the service graph as it stood at alert time and rules out every other suspect with stored Cypher proofs anyone can re-run. Steps 4 and 5 below come from its explanation predicate and its rollback rehearsal.
Kaizen · Kamran Pathan, Sanskar Joshi, Akshay Nazare, Yash Chandnani · See the code · Blog
It walks a graph of commits, functions, deployments and errors from the failing stack trace back to the commit. Every ranking feature is a Cypher query, and the LLM never sets a score. A confident verdict needs a stack-level link in the graph, and otherwise it abstains. Step 6 comes from there.
Both teams built and scored their own benchmarks.
| Builders' own test | Graph | Baselines |
|---|---|---|
| Incident Commander, exact root cause on 50 faults injected into a simulated company, the same LLM behind every approach in a run | 50/50 with each of six LLMs | Full catalog in the prompt 15 to 27 of 50, vector RAG 4 to 8 of 50 |
| Kaizen, right commit first on 28 replayed scenarios | 89% | Keyword search 39%, latest commit 32% |
| Kaizen, the 18 scenarios held out from tuning | 83% | Keyword search 44%, latest commit 28% |
| Kaizen, confidently wrong on the same 28 | 0% | Keyword search 61%, latest commit 68% |
| Kaizen, right commit first with the call path feature removed | 57% | None |
Read both with care, and the builders tell you why. Nihesh writes that graph accuracy is "partly true by construction", because each fault is checked against the same rule the agent uses and decoys are generated to fail it. So the 50/50 shows the agent finds the one qualifying change among decoys. It doesn't show the rule matches real outages. My favorite part is that this warning sits in his own docs. Kaizen's team made the latest commit the culprit in a third of the scenarios, so its 32% follows from that mix and isn't a rate for real teams. They call it a replay that "measures ranking quality, not live failure injection".
Step 1: Load services, changes and symptoms
pip install falkordb
docker run -p 6379:6379 -p 3000:3000 -it --rm falkordb/falkordb:latest
Every block below runs in order as one script. It was run on FalkorDB graph module 4.22.3 and on the 6.0.1 image, not on FalkorDB Cloud, and both gave the identical output shown. The services and changes are invented, built so exactly one change qualifies. That shows how the rule works and says nothing about accuracy.
Direction matters most. If checkout calls orders, a failure in orders can reach checkout, so the walk starts at the symptom and follows DEPENDS_ON forward.
import os, random
from falkordb import FalkorDB
db = FalkorDB(port=int(os.getenv("FALKORDB_PORT", 6379)))
g = db.select_graph("tut-rootcause")
# ["a", "b"] means a calls b, so a failure in b can reach a.
DEPS = [["gateway", "checkout"], ["checkout", "orders"], ["orders", "orders-db"],
["checkout", "pricing"], ["gateway", "search"], ["mailer", "orders"]]
SYMPTOMS = [["orders", "10:00"], ["checkout", "10:02"], ["gateway", "10:05"]]
# Zero-padded times sort as text. Use epoch seconds in production.
CHANGES = [["chg-01", "deploy", "orders", "09:37"], ["chg-02", "deploy", "mailer", "09:58"],
["chg-03", "deploy", "checkout", "09:50"], ["chg-04", "cert", "orders", "09:45"],
["chg-05", "deploy", "orders-db", "09:41"], ["chg-06", "deploy", "orders", "10:07"],
["chg-07", "deploy", "orders", "07:12"]]
rng = random.Random(7) # generated background changes
for i in range(11, 15):
CHANGES.append([f"chg-{i}", rng.choice(["deploy", "flag"]),
rng.choice(["gateway", "checkout", "search", "pricing", "mailer"]),
f"09:{rng.randint(5, 55):02d}"])
g.query("""UNWIND $rows AS r MERGE (a:Service {name: r[0]}) MERGE (b:Service {name: r[1]})
MERGE (a)-[:DEPENDS_ON]->(b)""", {"rows": DEPS})
g.query("""UNWIND $rows AS r MATCH (s:Service {name: r[2]}) MERGE (c:Change {id: r[0]})
SET c.kind = r[1], c.at = r[3] MERGE (c)-[:CHANGED]->(s)""", {"rows": CHANGES})
g.query("""UNWIND $rows AS r MATCH (s:Service {name: r[0]})
MERGE (y:Symptom {incident: 'inc-1', service: r[0]})
SET y.onset = r[1], y.signature = 'latency' MERGE (y)-[:ON]->(s)""", {"rows": SYMPTOMS})
for label in ["Service", "Change", "Symptom"]:
print(label, g.ro_query(f"MATCH (n:{label}) RETURN count(n)").result_set[0][0])
Output:
Service 7
Change 11
Symptom 3
The writes use MERGE, as Kaizen does, so a re-run creates no duplicates.
Try it. Run this against a free instance, passing your host, port, username and password to FalkorDB(). Start free on FalkorDB Cloud.
Step 2: Write the no path, no blame query
Start at a hurt service, walk its dependencies, and return only changes on that walk, with the path as evidence.
REACH = """
MATCH p = (:Service {name: $symptom})-[:DEPENDS_ON*0..6]->(:Service)<-[:CHANGED]-(c:Change)
WHERE c.at >= $since AND ($id IS NULL OR c.id = $id)
RETURN c.id, c.kind, c.at, [n IN nodes(p) | coalesce(n.name, n.id)]
ORDER BY c.at DESC, c.id"""
def reach(graph, symptom, change_id=None, since="09:00"):
params = {"symptom": symptom, "id": change_id, "since": since}
return graph.ro_query(REACH, params).result_set
for cid, kind, at, path in reach(g, "checkout"):
print(cid, kind, at, " > ".join(path))
Output:
chg-06 deploy 10:07 checkout > orders > chg-06
chg-03 deploy 09:50 checkout > chg-03
chg-04 cert 09:45 checkout > orders > chg-04
chg-05 deploy 09:41 checkout > orders > orders-db > chg-05
chg-01 deploy 09:37 checkout > orders > chg-01
chg-11 flag 09:30 checkout > chg-11
The newest deploy before the first symptom, chg-02, isn't there. The agent can't blame it.
Step 3: How do you know the empty result is right?
A typo in a label returns nothing too, so check why it's empty. Run four checks.
# 1. The deploy exists, and it is the newest one before the first symptom.
print(g.ro_query("""MATCH (c:Change {kind: 'deploy'})-[:CHANGED]->(s:Service) WHERE c.at < '10:00'
RETURN c.id, s.name, c.at ORDER BY c.at DESC LIMIT 1""").result_set[0])
# 2. The rule returns nothing for it on every symptom, and finds the older deploy.
for symptom, _ in SYMPTOMS:
print(symptom, reach(g, symptom, "chg-02"), "chg-01 rows:", len(reach(g, symptom, "chg-01")))
# 3. Ignore direction and the two services do connect.
print("hops without direction:", g.ro_query("""
MATCH p = (:Service {name: 'checkout'})-[:DEPENDS_ON*0..6]-(:Service {name: 'mailer'})
RETURN min(length(p))""").result_set[0][0])
# 4. Add one edge on a copy, and the same query finds a path.
copy = g.copy("tut-rootcause-whatif")
copy.query("""MATCH (a:Service {name: 'orders'}), (b:Service {name: 'mailer'})
CREATE (a)-[:DEPENDS_ON]->(b)""")
print("with orders calling mailer:", reach(copy, "checkout", "chg-02")[0][3])
copy.delete()
Output:
['chg-02', 'mailer', '09:58']
orders [] chg-01 rows: 1
checkout [] chg-01 rows: 1
gateway [] chg-01 rows: 1
hops without direction: 2
with orders calling mailer: ['checkout', 'orders', 'mailer', 'chg-02']
The change exists, and the query works, because it finds chg-01. The services are 2 hops apart, so an agent that ignored direction would blame chg-02. But mailer calls orders, and no hurt service calls mailer. Add that edge and the path appears, so the graph's shape produced the empty result.
Two limits. "No path" only means no path in the graph you loaded, so a missing dependency clears a guilty change. Incident Commander also builds failure edges from observed traffic for that reason. And direction is a model too. A changed caller can break a healthy service by sending bad input, and Kaizen's path feature checks both directions. If your incidents look like that, give that failure its own edge type.
Step 4: Why isn't a path enough?
In the Step 2 output, several changes have a path to checkout.
In the builder's words. "Topological reachability alone does not work." Nihesh Rachakonda, Incident Commander
Its answer is a predicate with five clauses. This query uses four of them. The change landed before the first symptom, reaches every symptom, sits on a service among the first to fail, and is a kind that can produce the symptom. The fifth, which you can add next, checks that onset order agrees with hop distance. The CAN_CAUSE table here is a sample, so write yours from your own incidents.
CAN_CAUSE = {"deploy": ["latency", "error_5xx", "timeout"], "flag": ["error_5xx"], "cert": ["tls_error"]}
VERDICT = """
MATCH (s:Symptom {incident: $inc})
WITH min(s.onset) AS first
MATCH (s:Symptom {incident: $inc})-[:ON]->(hurt:Service)
MATCH (c:Change)-[:CHANGED]->(svc:Service) WHERE c.at >= $since
WITH first, c, svc, s, shortestPath((hurt)-[:DEPENDS_ON*0..6]->(svc)) AS p
WITH first, c, svc, collect({onset: s.onset, sig: s.signature, hops: length(p)}) AS ev
RETURN c.id, c.kind, svc.name, c.at, CASE
WHEN c.at >= first THEN 'landed after onset'
WHEN any(e IN ev WHERE e.hops IS NULL) THEN 'no path'
WHEN none(e IN ev WHERE e.hops = 0 AND e.onset = first) THEN 'not the origin'
WHEN any(e IN ev WHERE NOT e.sig IN coalesce($can_cause[c.kind], [])) THEN 'wrong signature'
ELSE 'qualifies' END
ORDER BY c.at DESC, c.id"""
def verdicts(graph, inc="inc-1", since="09:00"):
params = {"inc": inc, "since": since, "can_cause": CAN_CAUSE}
return graph.ro_query(VERDICT, params).result_set
for row in verdicts(g):
print(*row)
Output:
chg-06 deploy orders 10:07 landed after onset
chg-02 deploy mailer 09:58 no path
chg-03 deploy checkout 09:50 no path
chg-04 cert orders 09:45 wrong signature
chg-13 deploy search 09:42 no path
chg-05 deploy orders-db 09:41 not the origin
chg-12 deploy gateway 09:39 no path
chg-01 deploy orders 09:37 qualifies
chg-11 flag checkout 09:30 no path
chg-14 deploy mailer 09:18 no path
Every ruled-out change states the first clause it failed. Incident Commander calls this list an absence certificate. The older chg-07 would also qualify, so $since leaves it out. A window can also miss a latent bug, and Kaizen's results list latent bugs as a known limit.
Step 5: Rehearse the rollback on a copy
Before acting, remove the suspect on a throwaway copy and ask again. If nothing else qualifies, the suspect was necessary. If a rival survives, refuse to act. Incident Commander's real rehearsal does more, restoring the previous version and re-checking partial explanations.
def rehearse(change_id):
copy = g.copy("tut-rootcause-rehearsal")
copy.query("MATCH (c:Change {id: $id}) DETACH DELETE c", {"id": change_id})
rivals = [r[0] for r in verdicts(copy) if r[4] == "qualifies"]
copy.delete()
return f"REFUSE, still qualifying: {rivals}" if rivals else "CLEARED, nothing else qualifies"
print("chg-01 alone:", rehearse("chg-01"))
g.query("""MATCH (s:Service {name: 'orders'})
CREATE (:Change {id: 'chg-20', kind: 'deploy', at: '09:44'})-[:CHANGED]->(s)""")
print("with a rival:", rehearse("chg-01"))
g.query("MATCH (c:Change {id: 'chg-20'}) DETACH DELETE c")
Output:
chg-01 alone: CLEARED, nothing else qualifies
with a rival: REFUSE, still qualifying: ['chg-20']
Step 6: Give the model a read-only tool and a gate
The model picks tools and writes the explanation. Plain code decides who gets blamed. Kaizen works this way, with a validator that rejects any node id no tool returned. Incident Commander requires every verdict to pass a proof gate. Serve verdicts and accept_blame as the only tools, over MCP if you like. The claims below are fixed strings, and no LLM runs here.
def accept_blame(change_id, inc="inc-1", since="09:00"):
table = {r[0]: r[4] for r in verdicts(g, inc, since)}
survivors = [cid for cid, verdict in table.items() if verdict == "qualifies"]
if len(survivors) != 1:
return f"ABSTAIN: {len(survivors)} changes qualify, page a person"
decision = "ACCEPT" if change_id == survivors[0] else "REFUSE"
return f"{decision} {change_id}: {table.get(change_id, 'not a candidate')}"
for claim in ["chg-02", "chg-05", "chg-77", "chg-01"]:
print(accept_blame(claim))
print(accept_blame("chg-01", since="09:40")) # the window misses the culprit
try:
g.ro_query("CREATE (:Change {id: 'chg-99'})")
except Exception:
print("write refused")
Output:
REFUSE chg-02: no path
REFUSE chg-05: not the origin
REFUSE chg-77: not a candidate
ACCEPT chg-01: qualifies
ABSTAIN: 0 changes qualify, page a person
write refused
The ABSTAIN line is the one to keep. When nothing qualifies, the agent says so and pages a person. Kaizen's verdict likewise stays "ambiguous" on its 3 missed scenarios, a bug in one service with its symptom in another and no thrown exception.
Try it. Replace DEPS, SYMPTOMS and CHANGES with your own services and last incident, then run verdicts.
To go further, Incident Commander snapshots the graph as it stood at alert time and writes learned dependencies back with a confidence score. Kaizen goes down to function level, with one graph per repository.
To see how full projects scored, read how Graph Hacks teams find root causes with a graph.
If you want to keep going, read how a company brain stays safe with fixed read-only queries and 5 agent memory patterns from 647 Graph Hacks projects.
Frequently asked questions
What does no path, no blame mean in a root cause agent?
It means the agent can't name a change as the cause unless the graph holds a directed path from that change to every symptom. The path doubles as evidence a person can re-run. It rules suspects out, and checks on timing, origin and symptom type pick the cause.
Does the newest deploy usually cause the outage?
Nothing here measures that on real teams. In Kaizen's benchmark, blaming the latest commit was right 32% of the time on 28 scenarios, and the team made the latest commit the culprit in a third of them.
What if my dependency graph is missing an edge?
A guilty change can then look innocent, because no path exists. Treat "no path" as "no path in this graph", and abstain when nothing qualifies. Incident Commander also adds failure edges from observed traffic, and scored 10 of 10 on its injected undeclared couplings.
Do I need an LLM for a root cause agent?
Not for the verdict. Incident Commander's deterministic graph agent, with no LLM, scored the same 50 of 50 as its LLM runs in the builder's benchmark. In Kaizen, the LLM only writes the explanation and never sets a score.
Should a root cause agent roll back on its own?
Neither project does. Kaizen proposes a revert, verifies it and merges nothing until a person approves. Incident Commander rehearses on a clone, then opens a rollback PR and pages the right person.
Run your first no path, no blame check
Every project here runs on the same FalkorDB you can start as a free cloud instance, or with one Docker command, docker run -p 6379:6379 -p 3000:3000 -it --rm falkordb/falkordb:latest. Export your service dependencies and last week's deploys, load them as Service and Change nodes, and run the path query on your last incident.
Not ready to build yet? Join the FalkorDB Discord to get help from our engineers, share what you build, and hear about the next Graph Hacks first.