Chronos/DBWaitlist

Blog / AI agents

What happens when an AI agent acts on data that changed?

Nothing stops it: a database only notices two writers on one row, not a decision made from a row that moved. Record what each agent run read, and hold its merge when any of it changed.

Abhishek DG · 5 min read
  • AI agents
  • Stale reads
  • Correctness

Its change goes through, and nothing warns you. A database only notices when two writers change the same row. An agent that read a row, decided something from it, and wrote somewhere else conflicts with nothing, even if the row it read has changed since. The fix is to record what a run read and hold its merge when any of that moved.

What is a stale read?

An agent reads an account balance, sees enough money, and writes a payout. While it was working, the balance dropped. The payout row is new, so no other writer touched it, so there is no conflict. The payout merges on a decision made from a number that is gone.

  • 10:00the agent forks a world and reads accounts/1: balance 500decides a payout of 400 is fine
  • 10:02your app lowers accounts/1 to 100 in mainthe agent does not know
  • 10:03the agent writes a new row in payoutsno conflict: nobody else wrote that row
  • 10:04the agent mergesa payout of 400 against a balance of 100
No two writers touched the same row, so an ordinary merge sees nothing wrong. The decision was still made on a balance that no longer exists.

Why don’t conflicts catch it?

Because a merge conflicts on rows both sides wrote. Reads leave no mark. Raising the isolation level inside one transaction does not help either: an agent run is not one transaction. It is minutes of work in its own branch, merged later.

How do I hold a merge that relied on changed data?

Ask the world to check its reads when you fork it:

SQL
create world payout with (check_reads = true);-- ... the agent reads and writes in payout ...merge world payout;-- ERROR:  merging payout read rows that changed since it forked: accounts/1; nothing was merged:--         redo the work in a new world forked from now

The world records what it reads. At merge time, if any of it changed in the parent since the fork, nothing is merged. It has to be set when forking: reads made earlier are not known later.

For agents, turn it on once in their merge policy. Every world they fork then checks its reads, the agent cannot turn it off, and a merge that read changed rows waits for a person instead of failing:

SQL
alter merge policy careful set (check_reads = true);

What counts as “read”?

  • Rows, not whole tables, when the query says which. where owner = 'ana' reads Ana’s leads; a change to someone else’s lead does not hold the merge.
  • Only the columns used. select sum(amount) from orders where status = 'open' is not held when an open order’s notes changes, but is when its amount or status does.
  • Rows that would have been found. A row added in the parent that the agent’s lookup would have matched counts too.
  • A scan with no usable condition reads the whole table, as do full-text and vector searches. So does reading a great many rows one at a time: past 10,000 keys of one table, its reads count as the whole table.

Can the agent find out sooner than its merge?

Yes. On a long task, check between steps:

SQL
check reads of world payout;--  checked_against | changed-- -----------------+--------------------------------------------------  main            | read rows that changed since it forked: accounts/1

CHECK READS changes nothing; it lists what the world read that has moved. If something has, the agent rebases its world, reads those rows again and decides again, while redoing one step is still cheap. Over MCP the tool is check_reads.

What does this not cover?

  • Things the agent learned outside the database. A price it fetched from another service is not a read Chronos can check.
  • Rows the world wrote itself. Those conflict or settle as they always do.
  • Reads made before the check was on. Set it when forking, or in the policy.

More: Stale reads and scope. The same page covers declared scope, where a run says up front which tables and which tenant it means to change, and is held to it.

Questions

What is a stale read in an AI agent workflow?

The agent reads a row, makes a decision from it, and writes somewhere else, while the row it read changes in the meantime. No two writers touched the same row, so nothing conflicts, and the change lands on a decision made from data that no longer exists.

How do I stop an AI agent acting on outdated data?

Record what each run reads and compare at merge time. In Chronos, fork the world with check_reads = true or set it in the agent’s merge policy: if any row the run read changed since it forked, the merge is held and nothing is written.

Does checking reads block a merge whenever the table changed?

No. A filtered query reads only the rows and columns it used, so a change to another owner’s row, or to a column the query never read, does not hold the merge. Unfiltered scans and searches read the whole table.

Written by

Abhishek DG

Co-founder & CEO, 2090 Labs

Abhishek builds Chronos in Bangalore: the database where AI agents work in their own copy of your data. Before it he built TailsMart and ACRED India.

More about Abhishek

Keep reading

What happens when an AI agent acts on data that changed? · Chronos