<?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: Noam</title>
    <description>The latest articles on DEV Community by Noam (@__68217c4211c606c).</description>
    <link>https://dev.to/__68217c4211c606c</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%2F4263339%2F796db5e9-b068-46fe-a854-d6c5ed6d84e1.png</url>
      <title>DEV Community: Noam</title>
      <link>https://dev.to/__68217c4211c606c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/__68217c4211c606c"/>
    <language>en</language>
    <item>
      <title>Your agent's "done" is a self-report, so we read the row back</title>
      <dc:creator>Noam</dc:creator>
      <pubDate>Wed, 25 Nov 2026 15:00:42 +0000</pubDate>
      <link>https://dev.to/__68217c4211c606c/your-agents-done-is-a-self-report-so-we-read-the-row-back-4p25</link>
      <guid>https://dev.to/__68217c4211c606c/your-agents-done-is-a-self-report-so-we-read-the-row-back-4p25</guid>
      <description>&lt;p&gt;An agent tells a customer, "You're booked for Tuesday at 10:00". The tool returned {"id": 42}, the trace is green, and everyone moves on.&lt;/p&gt;

&lt;p&gt;Then one of these happens:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;row 42 was never written&lt;/li&gt;
&lt;li&gt;it was written with 11:00 instead of 10:00&lt;/li&gt;
&lt;li&gt;it was written twice&lt;/li&gt;
&lt;li&gt;it was right, and then someone moved it to 12:00&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of these show up in the trace. The trace records what the agent said happened. The only place that knows what actually happened is the system the tool wrote to.&lt;/p&gt;

&lt;p&gt;So we tried the boring approach: after the tool runs, go and read the record back.&lt;/p&gt;

&lt;p&gt;The idea is two parts:&lt;/p&gt;

&lt;p&gt;Record the claim: &lt;/p&gt;

&lt;p&gt;A decorator on the tool runs it unchanged, then saves a small row: which tool, the ID it returned, the values the agent passed, and a deadline.&lt;/p&gt;

&lt;p&gt;Check it later somewhere else:&lt;/p&gt;

&lt;p&gt;A separate worker process picks up those rows, looks the record up in your database, and compares fields.&lt;/p&gt;

&lt;p&gt;import verilays:&lt;/p&gt;

&lt;p&gt;verilays.init(os.environ["VERILAYS_DSN"])&lt;/p&gt;

&lt;p&gt;@verilays.action.postgres(tool_name="create_booking", db="bookings", table="bookings",&lt;br&gt;
                          lookup_field="id", fields_to_compare=["room", "start_time"],&lt;br&gt;
                          deadline="2m")&lt;br&gt;
def create_booking(room, start_time):&lt;br&gt;
    ...&lt;br&gt;
    return {"id": new_id}&lt;br&gt;
Found with the same values is verified. Found with different values is a mismatch, with the diff. Still not there at the deadline is missing.&lt;/p&gt;

&lt;p&gt;There's no model in the check. It's a lookup by ID and a field comparison, so there's nothing that can talk itself into "verified".&lt;/p&gt;

&lt;p&gt;Why not check inside the tool?&lt;br&gt;
That was the first thing we considered. Three reasons we didn't:&lt;/p&gt;

&lt;p&gt;The check would share the tool's bugs. If the tool writes to the wrong table, a check written by the same person in the same function will often read the same wrong table.&lt;br&gt;
Some writes are late. A tool that goes through a queue or a slow API can return success before the row exists. Checking once, right away, calls that a failure.&lt;br&gt;
It slows the tool down. The agent is waiting. The worker isn't.&lt;br&gt;
The parts that were harder than expected&lt;br&gt;
Late writes. The worker keeps checking a pending action until its deadline. A row that appears 15 seconds later is still verified. Only "still not there at the deadline" counts as missing.&lt;/p&gt;

&lt;p&gt;Changed after verified. A verified action is checked again until its deadline. If the row changes or disappears in that window, someone else touched it after the agent's write. We mark that ambiguous, not a failure, because the agent didn't do anything wrong.&lt;/p&gt;

&lt;p&gt;Duplicates. The same tool called with the same values inside a short window (1 minute by default) gets flagged as a duplicate of the first call.&lt;/p&gt;

&lt;p&gt;"We never found out" isn't "missing". If the check itself keeps failing (the database times out, say) until the deadline, the action is expired. It would be unfair to blame the agent for our own check failing.&lt;/p&gt;

&lt;p&gt;Clocks. The deadline is set by the database's clock and compared with the database's clock. A worker whose clock runs ahead would otherwise mark things missing too early.&lt;/p&gt;

&lt;p&gt;Never break the agent. If the decorator can't record the call, or a setting is wrong (deadline="5 min"), the tool still runs and returns normally, and a warning says it isn't being checked.&lt;/p&gt;

&lt;p&gt;Read-only. The worker opens the connection with default_transaction_read_only=on, so Postgres refuses writes from it even if the user in the URL could write. It also stores only the lookup field and the compared fields, so something like a card number never reaches its table.&lt;/p&gt;

&lt;p&gt;What it looks like&lt;br&gt;
This is real output from the demo, which runs a booking agent through 8 scenarios (a silent no-op, wrong values, a late write, a duplicate, a row someone overwrites, a tool that raises, and so on):&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            verified  mismatch  missing  failed  ambiguous
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;create_booking         4         1        1       1          1&lt;/p&gt;

&lt;p&gt;Needs attention&lt;br&gt;
e54edf4d  missing      room=noop start_time=10:00  not found after 0:00:40&lt;br&gt;
75a021a2  mismatch     room=wrong start_time=10:00  start_time: expected 10:00, got 11:00:00&lt;br&gt;
6b909e47  duplicate    room=dup start_time=10:00  duplicate of 1a88226b, 0s later&lt;br&gt;
496a4779  ambiguous    room=overwritten start_time=10:00  changed after verified: start_time 10:00 → 12:00:00&lt;br&gt;
970b8ac4  failed       room=raises start_time=10:00  RuntimeError('booking API down')&lt;br&gt;
If you use Langfuse, each verdict also shows up as a score on that tool call in the trace.&lt;/p&gt;

&lt;p&gt;What it doesn't do&lt;br&gt;
Postgres is the only built-in check. For anything else (a calendar API, a CRM), you write a small verify function that reads the record through that system's client.&lt;br&gt;
It checks that the record matches what the agent passed, not whether it was the right thing to do.&lt;br&gt;
It only sees tools you wrap. If the agent never calls the tool, there's nothing to check.&lt;br&gt;
Try it&lt;br&gt;
We open-sourced it (Apache-2.0). The demo needs only Docker and takes about a minute:&lt;/p&gt;

&lt;p&gt;git clone &lt;a href="https://github.com/yinoni/verilays" rel="noopener noreferrer"&gt;https://github.com/yinoni/verilays&lt;/a&gt;&lt;br&gt;
cd verilays&lt;br&gt;
docker compose run --build --rm demo&lt;br&gt;
Repo: &lt;a href="https://github.com/yinoni/verilays" rel="noopener noreferrer"&gt;https://github.com/yinoni/verilays&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm curious how others handle this today. Do you read the record back, trust the tool's return value, or check it some other way?&lt;/p&gt;

</description>
      <category>python</category>
      <category>opensource</category>
      <category>ai</category>
      <category>postgres</category>
    </item>
  </channel>
</rss>
