# An audit log for AI agents’ database changes

Source: https://osevel.com/learn/ai-agent-audit-log/ · reviewed 2026-11-28

> An audit log for an AI agent should answer four questions for every change: which agent, which statement, which rows, and what they looked like before and after. Keep it inside the database, owned by a role the agent cannot use, so the agent cannot rewrite its own history.

## What to record

- The agent, by name, and the session it worked in.
- The statement it sent, exactly.
- Every row it changed, before and after, and which columns changed.
- For a change that needed approval: who approved it, and when.

## Where to keep it

In the same database, written by a trigger and owned by a role nobody logs in as. Server logs show that a statement ran; they rarely keep the rows it changed, and they are not where you look when you want one row back.


## What OsBase does

- A trigger in your own database keeps every row an agent changes, before and after, with the agent’s name and session.
- The change log is owned by a role nobody logs in as; the agent’s role cannot write to it.
- Approvals are recorded with proof of who signed them.
- An undo that finds code trying to change the change log stops and rolls back.
- An auditor agent can read the log and report: counts and names, not rows.

## Questions

### Does it record my application’s writes too?

No. Only agents go through OsBase; your application and your admin write as before, unrecorded.

### How do I read it?

osevel log in the terminal, filtered by agent if you like, or the change timeline in the dashboard.
