Most teams still treat database work as the dangerous part of automation. Let the AI agent draft the email, summarize the ticket, or write the migration plan. But when it needs to inspect, reshape, enrich, reconcile, or repair real operational data, the workflow suddenly becomes a patchwork of staging tables, exported CSVs, copied databases, and nervous human review.
That caution is healthy. The tooling is not.
If agents are going to work with relational data, they need a workspace model built for exploration. Not a bigger prompt. Not a “be careful” system message. Not a throwaway staging table named after whoever was on call. They need the data equivalent of a branch: an isolated, reproducible state where an agent can try a change, show the diff, handle conflicts, and ask for a merge decision before anything touches the canonical record.
A new paper, “Git4Data: Database-Native Version Control for AI Agents,” points directly at this gap. The authors argue that LLM agents increasingly explore many candidate states of relational data in parallel, but today’s tools split the problem awkwardly. Git-style source control is excellent for code, but does not scale naturally to large datasets. Relational databases manage large data well, but rarely expose native branching, comparison, and merging as first-class operations. Git4Data proposes treating a database as a repository and a table as a versioned object, with SQL extensions for snapshot/tag, branch, diff, and merge operations.
That is the right shape of the problem.
The core issue is not whether an agent can produce a valid SQL statement. The issue is whether the system can preserve the agent’s working state, compare it against the baseline, explain what changed, and reject or merge it under an explicit policy. A competent data agent should be able to say, “Here is the branch I created for customer-deduplication-run-42. Here are the rows I touched. Here are the conflicts. Here is the confidence boundary. Here is the approval I need.”
That is very different from “I updated the staging table.”
Staging tables are easy to create and hard to govern. They often lack a clear parent state. Their naming is inconsistent. Their lifecycle depends on human discipline. Their diffs are usually custom queries written after the fact. Their merge path is whatever script an engineer trusts today. In a human-only workflow, that mess is tolerable because context lives in the team’s heads. In an agent workflow, it becomes a source of invisible risk.
The Git4Data paper is interesting because it moves the branch/diff/merge vocabulary into the database itself. The authors describe a design implemented in MatrixOne using immutable object storage and MVCC so versioning costs scale with the size of the change rather than the size of the dataset. They also report that Git4Data outperforms DoltDB by up to an order of magnitude on their BranchBench workloads. Those are research results, not a universal buying recommendation. But the architectural lesson is broader than one implementation: data agents need native, cheap, inspectable state forks.
Transaction isolation is not enough. PostgreSQL and other relational systems already provide isolation levels that control how concurrent transactions see each other’s changes. That matters for correctness during a transaction. But agent work often spans longer loops: retrieve, inspect, propose, transform, validate, retry, call another tool, ask for review, and only then commit. A transaction is a concurrency primitive. A branch is an operational workspace.
Once you view data-agent work this way, the control plane becomes much clearer.
First, every material data task should start on a branch. The branch should be tied to the initiating user, workflow, ticket, policy, and agent identity. If the agent is enriching product records, reconciling duplicate accounts, or preparing a migration, its writes should accumulate in a named workspace instead of scattering through temporary tables.
Second, the diff should be the approval artifact. Human reviewers should not have to read a chat transcript and infer the database impact. They should see row-level and column-level changes, deleted records, inserted records, confidence bands, and policy-sensitive fields. If the agent claims it only normalized addresses, the diff should prove it did not also alter billing status.
Third, merge should be a governed operation, not a script someone runs when the demo looks good. The merge policy should define conflict handling, required approvals, validation checks, rollback expectations, and which fields are never agent-mergeable without elevated review. This is where data infrastructure meets enterprise risk management: map the action, measure the impact, manage the approval path, and govern the evidence trail.
Fourth, the branch should connect to the broader agent safety stack. The “Irreversibility Budget” paper frames a related problem at the fleet level: individually authorized effects can still overdraw a tenant’s total risk when many agents act under the same trigger. A database merge is exactly the kind of effect that should be charged against a shared risk budget. A tiny correction to one record is different from a million-row rewrite, even if both pass a local permission check.
Fifth, the branch history should join the agent’s flight recorder. Another recent paper, “Agent Flight Recorder,” argues for structured, tamper-evident audit trails for long-horizon tool-using agents. That idea becomes more powerful when the recorded action is not merely “ran SQL,” but “created branch, produced diff, requested merge, resolved conflicts, merged under policy.” The data state and the action provenance should line up.
This is also a practical lesson for teams building agents today, before database-native version control is standard. You can still move toward the pattern.
Create per-task schemas or isolated database clones with consistent naming. Store the parent snapshot identifier. Generate deterministic diffs before approval. Separate exploration credentials from merge credentials. Require typed merge requests instead of free-form “looks good” chat approvals. Log the agent’s intent, tool calls, validation output, reviewer, and final write path. Sample merged changes after the fact. For higher-risk workflows, cap the number of affected records or total value at risk per run.
The point is not to recreate Git inside every production database by hand. The point is to stop pretending that agent data work is safe because it happened outside the main table until the last minute. Safety comes from explicit state, explicit comparison, and explicit authority.
This is where many enterprise AI programs will separate from demos. Demos show that an agent can find the right query. Production asks whether the same agent can explore without contaminating the record, explain every proposed change, survive conflict, and merge only when the organization’s policy says the risk is acceptable.
A data agent should not be trusted because it sounds careful. It should be trusted only inside infrastructure that makes carefulness observable.
The branch is that infrastructure boundary. It gives the agent room to work, gives reviewers something concrete to inspect, and gives the organization a place to attach policy before irreversible changes become operational facts. For teams serious about AI automation, the next database question is no longer just “Can the model write SQL?”
It is: “Where does the agent’s version of the truth live before we let it become ours?”
Build AI Systems That Survive Contact With Real Work
We help teams turn AI research into practical automations, agent workflows, and operational systems that can be evaluated and improved.
Get the Field Guide — $10 →