DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • SQL Ledger in SQL Server 2022: Tamper-Evident Audit Trails and Immutable Ledger Tables
  • Develop a Scalable Event Listener for Blockchain
  • The Query Takes 20 ms. Why Does the API Take Two Seconds?
  • Relate: A SQLite-Style Graph Database

Trending

  • Claude Code Superpowers: The 5-Tool Stack That Ends Limits and Context Amnesia
  • Telling a Language Model What a Fraud Ring Looks Like: A Snowflake Experiment
  • When 12 Hours of Offline Changes Collide: Designing Conflict-Safe Mobile Sync
  • Choosing Voice AI Infrastructure: 7 Capabilities To Evaluate

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Data Engineering
  3. Databases
  4. Relate, Jev, and MCP: A Judgment Ledger for Agent Decisions

Relate, Jev, and MCP: A Judgment Ledger for Agent Decisions

Logging agent decisions in a graph database makes them queryable, while a Tube-walk experiment revealed differences in model decision quality.

By 
Akmal Chaudhri
DZone Core CORE ·
Dec. 04, 26 · Analysis
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
0 Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

In a previous article, we introduced Relate, a SQLite-style graph database. In this article, we'll use Relate to create a judgment ledger for agent decisions, working with several popular technologies.

Most agent demos show an agent answering a question. The reasoning behind the answer disappears into a log. This article shows a different approach: every judgment an agent makes becomes a record in a graph database. Afterward, you can query the agent's decisions the way you query any other data.

The vehicle is a small experiment on the London Underground (Tube). An agent walks from Kennington to Euston one hop at a time and cannot see the map. The idea being tested is the judgment ledger, and the Tube is only a convenient place to test it.

The full source code and technical report, with the method, every query and result table, and the Relate engineering notes, accompany this article on GitHub.

Relate In One Paragraph

Relate (formerly CypherLite) is an embedded graph database from Neo4j. The whole graph lives in a single file, you query it with Cypher and there is no database server or plugin to set up. Install it with pip install relate-db; it imports as relate.

Here it holds two things in one graph:

  1. The London Underground (349 stations and 458 connections)
  2. The ledger of everything the agent decides

How the Walk Works

At each station, the agent asks for its legal moves. As shown in Figure 1, TypeSafe AI's Jev scores the options, returning a probability for each one. The margin, the top probability minus the second, decides who picks: if it is 0.2 or more, the agent moves; if it is lower, a person chooses. Either way, the decision is written back to the graph.

The normal decision path. The agent can also ask a person at any margin, for example when it cannot satisfy a passenger constraint

Figure 1. The normal decision path. The agent can also ask a person at any margin, for example when it cannot satisfy a passenger constraint.


A judgment ledger, as used here, is a persistent record of an agent's decision state, the alternatives available, the model's assessment of each, the action selected, who had the authority to decide, and the explanation. In graph terms, each decision is a Step node linked to the station where it happened (AT), to every option weighed (CONSIDERED, with Jev's probability on the edge) and to the station chosen (CHOSE). Because it sits in the same graph as the map, a query can join the two.

The agent works through seven tools exposed by an MCP server, and it cannot write its own queries:

  • start_walk starts a walk
  • where_am_i reports the current station, the goal, and the hops taken
  • next_hop lists the legal moves
  • judge_hop asks Jev and writes the step
  • move and ask_human act
  • ledger_report runs fixed read-only reports

Three rules are enforced by the server rather than left to the model. A move must be one that next_hop offered, so an invented station is refused. An agent cannot move itself when the margin is below 0.2; it has to call ask_human. And it cannot move onto a station it has already visited twice, which we added after a failure described below.

One distinction matters for anyone thinking about human oversight. The server enforces that escalation happens, not who answers it. Whether the responder is a person depends on the MCP client, and a client that is itself an agent may answer for them.

What the Margin Means and What It Doesn't

A margin of 0.8 means Jev had a clear favorite. A margin near 0.02 means several options were nearly tied. The margin measures how strongly Jev favors its top option over the runner-up, not whether that option is correct, so a confident-looking preference can still be wrong. The 0.2 threshold is a prototype policy: chosen by hand, configurable, and not validated as a safety boundary. Jev's probabilities summed to about 1 in the runs shown, but we did not test whether they were calibrated, so read 0.36 as a relative weight, not a 36 percent chance of being right.

What the Ledger Shows

We ran the walk with Green Park suspended after the first hop. The clear walk reached Euston in six hops; the disrupted one took eight, detouring through Embankment, Charing Cross and Piccadilly Circus. Jev could not see the map, only a sentence describing each option, such as "Westminster (Jubilee line). 4 stops from Euston. Status: clear. Further on: Green Park suspended." That sentence was enough to pull the choice away from the direct route.

At Westminster the margin collapsed, and a person was asked. The ledger holds exactly what Jev weighed there, and a single query retrieves it:

Cypher
 
MATCH (s:Step {walk: $w, n: $n})-[c:CONSIDERED]->(o:Station)
RETURN o.name AS option, c.probability AS probability
ORDER BY probability DESC
Option Probability
Embankment 0.36
St. James's Park 0.34
Waterloo 0.25
Green Park (suspended) 0.05


The ranking is sensible: the suspended station got almost no weight. Across runs, the margin at this hop ranged from about 0.02 to 0.13, because hosted Jev is not deterministic, so exact numbers should not be quoted as fixed. The ledger also exposed a weak spot. Waterloo, which the passenger had just left and which the option text marked as already visited, still drew 0.25. That did not change this walk's outcome, but it foreshadows what happens next, and without a record of every option, it would be invisible.

Queries over the whole ledger work the same way. The five shakiest hops, the options that nearly won, and the steps where the agent overrode Jev's top pick are each a short Cypher statement. A join with the line data shows which lines were available on each chosen hop, with one caveat: the ledger records every line that serves a link, not the one the passenger rode.

Giving the Agent to a Language Model

The scripted loop is a stand-in. The more interesting runs let a language model choose the tools, with a one-sentence reason stored with every move. Jev scores hops for reliability only and never sees the passenger's constraints. If the passenger says "avoid the Northern line," the model may override Jev's pick and explain why. That makes the overrides report useful, because it shows where the model disagreed with Jev and what it said.

The constraint is about the line the passenger rides, not the lines that serve a connection, so a hop served by "Bakerloo, Northern" satisfies it. Models differed on whether they applied that rule.


Notebook (in-process tools) MCP server
Models gpt-4o-mini, gpt-6-luna, gpt-6.1-terra gpt-6.1-terra, claude-sonnet-5-5
Runs 1 or 2 per model and condition 1 per model and condition, plus reruns of the loop case
Setup Same Tube graph, Green Park suspended after hop 1, same prompt for every model, provider-default generation settings


These are observations, not benchmarks. With no constraint, every model was fine. On the Northern-line constraint, GPT-6 Luna applied the any-listed-line rule inconsistently: it overrode Jev's confident pick at Charing Cross because the link lists the Northern line, yet accepted the final hop into Euston, which also lists it. Its walks took 16 and 18 hops against 8 for GPT-6.1 Terra, with loops through Victoria and one move onto a suspended station that its reasoning did not mention. Even so, the 18-hop walk stayed within the legal moves the tools offered and reached Euston. The restrictions limited what the agent could do, but they did not make its reasoning correct.

Two Models, Two Failure Modes

The sharper contrast came through the MCP server. On the standard runs, Terra and Claude took the same routes: 8 hops with no constraint, 8 on the Northern constraint and 7 on the Jubilee constraint, with reasons that matched the tool output. Then we changed one thing: at the Westminster tie, a person chose St. James's Park, Jev's narrow top pick, which leads away from the Charing Cross route.

Model Hops What happened
gpt-6.1-terra 26 (turn limit) Followed Jev back and forth between Victoria and Pimlico
claude-sonnet-5-5 22 Noticed the loop and avoided it, but wandered
gpt-6.1-terra, with the loop guard 16 The guard refused moves; a person steered it out


Terra Follows Jev Into The Loop

Jev kept favoring Pimlico from Victoria and Victoria from Pimlico, with margins between 0.3 and 0.8. That is far above the 0.2 threshold, so the margin gate never stopped the model. Terra followed Jev for 20 hops, noting each time that the station had already been visited, until the turn limit ended the run. The "visited" flag in the option text did not stop Jev from favoring a station it had already seen.

Claude Avoids The Loop And Wanders

Claude followed Jev to Victoria and Pimlico, but after one return, its reasons began saying the walk was looping, and it chose unvisited stations instead. It reached Euston in 22 hops by way of Sloane Square, South Kensington, Knightsbridge, Gloucester Road, and the Central line. It overrode Jev seven times, at probabilities as low as 0.03 and 0.06 against top picks of 0.76 and 0.94. Each override has a reason in the ledger, though a few describe "dead-end loops" and a "closed-off area" the tools never reported. Claude never found the open Embankment route.

The takeaway is that "did it reach Euston?" is the wrong test. Both models arrived. The quality of the decisions along the way differs, and only the ledger shows how.

The Guard

The failure led directly to the server-side loop guard: an agent may not move onto a station it has already visited twice and move refuses and tells the model to call ask_human. With the guard on, Terra on the same path looped until the guard refused, then asked a person at each of the next four hops and was steered back to Embankment and on to Euston in 16 hops. The guard caps a loop but does not prevent one, because Jev still favors the visited station and a person has to get the walk out. It also applies only to the agent's own moves: a person's choice is checked against the legal moves but not blocked by the visit count.

Why This Matters Beyond The Tube

The pattern is what matters, not the London Underground. Because decisions are data, a path can be reconstructed from the ledger instead of inferred from logs. Models can be compared by their recorded decisions, as above. Low-margin decisions can be escalated to a person, and the ledger records that they were. When something goes wrong, the failing step, the options it weighed, and the reason given are one query away. And the history is available for tuning prompts, models, and thresholds. Any agent that picks among enumerable options, such as a workflow step or a planning move, could write the same kind of record.

Limits

This is a prototype and its limits are real. The margin measures preference strength, not correctness; the 0.2 threshold is untested policy, and hosted Jev is not deterministic. The model comparisons rest on one or two runs per condition. The ledger records every line serving a link, not the one the passenger rode. It walks one journey at a time, held in memory. ask_human depends on the client supporting MCP elicitation. The server needs mcp 2.x, and it has been driven by the official client and by FastMCP's client but not yet by an application such as Claude Desktop. The Ollama adapter has only had its message conversion tested.

Summary

The lesson is not about the London Underground. An agent's decision-making can itself become structured, persistent, queryable data. Once it is, auditing behavior, comparing models, and examining when a person should step in become questions that can be answered directly from the graph. Relate makes that easy to try: one file, one pip install and the ledger and the map in the same place.

The full source code and technical report, with the method, every query and result table, and the Relate engineering notes, accompany this article on GitHub.

Database Ledger (software)

Opinions expressed by DZone contributors are their own.

Related

  • SQL Ledger in SQL Server 2022: Tamper-Evident Audit Trails and Immutable Ledger Tables
  • Develop a Scalable Event Listener for Blockchain
  • The Query Takes 20 ms. Why Does the API Take Two Seconds?
  • Relate: A SQLite-Style Graph Database

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook