An AI agent's audit trail should record one entry for every change the agent makes to a live system: when it happened, which tool made it, what it was asked to change, whether it worked, and the error if it didn't. Leave customer details such as addresses and free-text notes out of it, keep it for a fixed period, and write each entry at the moment a change a person approved is carried out.
What is the purpose of an audit trail for AI agents?
An audit trail answers the question you ask the morning after something looks wrong: did the agent do that, and if so, when, and was it approved? Without one, you're piecing it together from a chat history that may be gone, summarised or simply wrong about what happened.
An agent can make a lot of changes in a short time and doesn't remember them afterwards, so the log is its memory. It's also how you check that your rules are holding. If the rule is that the agent only changes prices after a person approves, the log is where you see each price change and can match it to an approval.
Deciding which jobs an agent may do on its own is a separate question, covered in how much an AI agent should be allowed to do: act, draft or escalate. The audit trail is how you check, afterwards, that it stayed inside those limits.
What should an AI agent's audit trail record?
Write one entry for each change the agent makes to a live system. Each entry needs five things:
- When. A timestamp added by the system at the moment the change is made. The agent shouldn't supply it, so it can't get it wrong.
- Which tool. The name of the action: set a price, archive stock items, create an order.
- What it was asked to change. Enough to identify the change without copying the whole record: the stock item IDs and SKUs, the old and new values, the order lines.
- The result. Worked or failed. Two fixed values, so you can filter for failures in seconds.
- A plain-English line. What was done, in words a person can read at a glance, or the error message if it failed.
Reads are a different matter. An agent that only looks things up hasn't changed anything, so the audit trail can stay focused on writes. That keeps it short enough that someone actually reads it.
Record failures as well as successes
A failed change is often the most useful entry in the log. It tells you the agent tried, what stopped it, and whether anything was left half done. If you only log successes, a failure looks the same as nothing happening.
Pay special attention to changes that fail part-way. If an agent is updating ten prices and the sixth one fails, the log should say which five were already changed. Otherwise someone has to check every record by hand to find out.
What should you keep out of the log?
Keep customer personal data out. An audit log is kept and read for its own purpose, so it shouldn't become a second copy of your customer records. Record identifiers and counts, not the details themselves:
- the SKU and quantity, not the customer's name and address;
- how many notes were added, not what they said;
- whether there was a separate billing address, not the address itself.
Free-text fields deserve particular care. An order note or a message can hold almost anything a customer or a member of staff typed, so the safe default is to count them and leave the text where it already lives. Data protection rules vary from country to country, so check the rules where you trade before deciding what your own log keeps.
How long should you keep an AI agent's audit log?
Pick a fixed period and let entries expire on their own. Keeping everything forever builds up data you don't need, and deleting by hand means it gets forgotten. A fixed retention period, set when each entry is written, avoids both.
The right length depends on how far back you need to look when something goes wrong and on any record-keeping rules that apply to your business. There is no single number that suits everyone, and the example below uses that product's own setting, not a recommendation.
Pair the log with preview-then-confirm
An entry tells you what happened. On its own, it doesn't tell you whether anyone wanted it to happen. The fix is to write the entry at the confirm step of a preview-then-confirm flow.
The agent first prepares the change and shows a preview of exactly what will change, and nothing is written. A person says yes. Only then does the confirm step carry out that one change and write the audit entry. Because the confirm step is the only way a change gets made, every entry in the log lines up with a preview a person approved. There's more on that flow in AI agent human approval: how preview-then-confirm works in practice.
This matters most when nobody is watching. An agent that runs on a schedule leaves the log as the only record of what it did, which is why it's one of the guard rails in running AI agents on a schedule.
An audit trail example: our Linnworks MCP server design
The change tools we designed for our Linnworks MCP server keep their audit log this way. The hosted service we sell today, the Hosted MCP Server for Linnworks, is read-only and doesn't offer these tools, so treat this as a worked example of the pattern rather than a product description.
Those change tools come in preview and confirm pairs. A preview reads the current values live, shows the before and after, and writes nothing. The confirm tool runs only after the person has said yes, works once, and expires 10 minutes after the preview. Audit entries are written only at that confirm step, so read-only lookups don't add to the log.
Say you ask Claude to change the retail price of one SKU, [EXAMPLE-SKU]. You see the preview with the old and new price and say yes. The entry written when the change is confirmed holds:
- When: a timestamp the server adds as it writes the entry.
- Tool: set retail price.
- Arguments: the stock item's ID and SKU, with the old and new price.
- Result: ok.
- Detail: a line naming each SKU with its old and new price.
If carrying out the change fails, the entry is marked as an error and the detail holds the error message instead. (A lost connection to Linnworks is handled separately: the person is asked to reconnect.) When a batch of price changes fails part-way, that message lists the SKUs that were already updated before the failure. When a new order fails part-way, the server tries to delete the half-built order, and the message says whether it managed to or gives the order ID to remove by hand.
For a new order, the entry keeps the location, each line's SKU, quantity, unit cost and tax rate, any order references, the number of notes and whether there was a separate billing address. It doesn't keep the addresses or the note text, because they can hold customer data the product doesn't keep.
Each entry is stored with a 90-day expiry, so it drops out of the log on its own after 90 days. That's that design's own setting, not a legal requirement or a figure to copy. What the hosted server does today is in the Hosted MCP Server for Linnworks and Claude.
A short checklist
- One entry for every change the agent makes, written by the system, not by the agent's own account of events.
- Time, tool, what was asked, result and a readable line in every entry.
- Failures logged as well as successes, including what had already changed.
- Identifiers and counts, not customer details or free text.
- A fixed retention period, set when each entry is written.
- Entries written at the confirm step, so each one matches an approved preview.
Want an AI assistant that reads your Linnworks data and can't change it? Have a look at the Hosted MCP Server for Linnworks, or browse the rest of the MCP-G blog.