H6.ai replays real invoice errors on database branches. Reproducible state is the missing half of agent tests
H6.ai tests its accounts payable agent against snapshots of the exact customer data behind each past error, using Lakebase branches. The test data, not the judge, makes the suite trustworthy.

An accounts payable agent matched an invoice to the wrong purchase order last month. The team fixed the prompt. Did the fix work? To answer that, you need to run the same invoice again against the same purchase orders, suppliers, accounts and policy settings that existed when it failed. In a live ERP, that state is gone: purchase orders have been received, suppliers updated, the period closed.
H6.ai, which automates accounts payable on top of customers’ existing ERPs, solved that with a database feature rather than a better judge. Its engineers described the approach in a Databricks post on November 12.
The setup
Each H6.ai customer gets a dedicated Lakebase Postgres database, Databricks’ managed Postgres, which isolates financial data on a multi-tenant platform. Lakebase supports branches: copy-on-write copies of a database at a point in time, created without copying data, sharing storage with the parent.
When an invoice is handled incorrectly, H6.ai keeps a branch as a snapshot of that moment: the purchase order state, suppliers, accounts, dimensions, history and policy settings behind the mistake. The snapshot becomes a permanent test case.
- Snapshot branch
- Migrate
- Fork a run branch
- Process the invoice
- Judge
- Delete the run branch
Each run is judged twice: by deterministic assertions where the right answer is known, and by a panel of AI judges built on models from different providers, each returning pass, fail or inconclusive with its reasoning. Unusual invoices are kept as permanent cases with their state and expected outcome. Tests never touch the live database or the customer’s ERP, and branch management runs under dedicated service principals with least-privilege access.
Why the state matters more than the judge
Most agent evaluation discussions are about scoring: which metrics, which judge model, which threshold. H6.ai’s case shows the other half. A test is only as good as the input it replays, and for agents that act on business data, the input is not the prompt. It is the whole state of the systems the agent reads.
Without that state, teams test against synthetic or current data and get a weaker answer to “is the fix right?” The agent might pass because today’s purchase order is already received, not because the matching logic improved. With the exact state preserved, a pass means the same situation now produces the right result.
This is the evaluation counterpart of the point we made about database branches for parallel coding agents: cheap, isolated copies of real state change what is practical to test.
What the case does not claim
The post is a customer story, not a product launch, and it publishes no accuracy or error-rate figures. Database branching makes tests reproducible; it does not make the agent’s financial decisions correct or establish compliance. The multi-model judge panel reduces the risk of one model’s blind spots but remains a judge, which is why the deterministic assertions sit next to it.
How to borrow the pattern without Lakebase
The idea travels to any stack that can snapshot data cheaply: database clones, point-in-time restores, or exported fixtures of the relevant records.
Capture state at the moment of failure. When a user reports a wrong action, save the records the agent read, not just the conversation.
Turn every serious error into a permanent case with its state, the expected outcome and who approved that expectation.
Run the full pipeline, isolated. Test the real tools against disposable copies, never against production systems.
Judge with rules first. Where the right answer is a fact, such as the matched purchase order or the posted account, assert it. Use model judges only for what cannot be asserted.