Guide

How to log and trace agent decisions for audit

An auditor will ask what the agent did, on what basis and under whose authority. Design the trace so that answer takes minutes, not weeks.

By iFortis Worldwide ResearchPublished Updated 3 min read

On this page

SummaryLog every agent task as one linked trace: the trigger, the identity and authority in force, each model call and tool call with inputs and outputs, the data sources used, any human decision and the final outcome. Record the versions of model, prompt and policy, protect the logs from change and set a retention period.

Start from the questions that will be asked

Audit logging is easier to design backwards. Imagine a regulator, an internal auditor or a customer disputing a decision six months from now. They will ask a small number of questions.

  • What exactly did the system do in this case?
  • What information did it rely on?
  • Which rules and limits applied, and were they followed?
  • Was a person involved, and what did they decide?
  • Which version of the system was running at the time?

If the trace answers these for any single case without engineering help, the design is sound.

One task, one trace

Give every task a unique identifier at the moment it starts and carry it through every step: each model call, each tool call, each handover to another agent or to a person. Record parent and child relationships so the sequence can be rebuilt as a tree. Open standards for distributed tracing work well here and avoid tying the record to one tool. Fragments scattered across application logs, a model gateway and a workflow engine, with no shared identifier, are the usual reason reconstruction fails.

What each record should hold

  • Who. The agent identity, the user it acted for if any, and the owner.
  • What. The action requested, the tool called, the arguments and the result.
  • Basis. The documents and records retrieved, with identifiers and versions, and the stated rationale produced for the decision.
  • Authority. The policy and limit checks run, and whether each passed.
  • Oversight. Any approval, amendment or rejection by a person, with name, time and reason.
  • Configuration. Model name and version, prompt version, tool versions and key parameters.
  • When. Timestamps from a synchronised clock.

Record the state of core systems before and after a write where that is practical. It shortens any later correction.

The explanation a model writes for its action is useful evidence. It is not a guaranteed account of how the output was produced. Treat it as a statement made at the time, and rely on the hard facts in the trace: the inputs, the sources retrieved, the checks passed and the action taken. Audit conclusions should rest on those.

Protect privacy in the logs

Complete traces contain personal and confidential data. Without care, the audit store becomes the largest uncontrolled copy of sensitive information in the company.

  • Mask or tokenise identifiers that are not needed for reconstruction.
  • Store references to source records instead of full copies where the source is itself retained.
  • Restrict access by role, and log access to the logs.
  • Apply retention periods that match legal and regulatory obligations, then delete.

Make the record trustworthy

Evidence is only useful if it could not have been altered. Write logs to append-only storage. Separate the duty of running agents from the duty of administering their logs. Consider hash chaining or a write-once store for high-stakes processes. Ensure the agent itself has no permission to modify or delete its own trail.

Two audiences, two views

Engineers need detailed traces to debug: token counts, latencies, raw payloads. Auditors and business owners need a readable case history: what happened, in order, in plain language, with links to evidence. Build both from the same underlying data. An operations view that only an engineer can interpret does not satisfy an audit.

Add aggregate reporting on top: volumes, limit breaches, override rates and exceptions by type. Patterns across thousands of cases show control weaknesses that single cases hide.

Test the trail before you need it

  • Pick ten completed cases at random and reconstruct each from logs alone.
  • Time how long it takes and note what was missing.
  • Include a case that was escalated and one that failed midway.
  • Ask internal audit to try it without the build team in the room.

Repeat after major releases. Logging is often the first thing to break quietly when a new tool or agent is added. For related practice, see observability, AI governance and our security, trust and governance work.

All insights RSS feed

Tell us the outcome you need

The first meeting is a working session about your situation, with an engagement lead, not a sales call.

Contact us Submit an RFQ