Academy · AI agent security

AI agent audit trail. What you will be asked, and what answers it.

Most systems already log that a credential was used. Almost none record which workload used it. That single gap is what turns an incident review into guesswork, and it is an identity design problem before it is a logging one.

The same call, two logs
ci-deploy-key usedSELECT on customers, 1 of 4 consumersUnattributable
cursor-agent usedSELECT on customers, 14,882 rowsAttributable
Triggered byIssue #4412, external contributorContext
KEY TAKEAWAYS
  • Most logs say a key was used. Few say which workload used it. That gap is the whole problem.
  • One identity per consumer is the precondition for a useful log. Shared credentials cannot be attributed, ever.
  • Keep the log longer than the detection gap. Incidents are usually found months later, not days.
  • Record the input that led to the action, not only the action. An agent steered by prompt injection looks normal in an action-only log.

Published Last reviewed

WHAT TO RECORD

Four things the log has to say.

In the order you will want them during an incident, which is not the order most systems record them.

01
Which identity made the call

The single most valuable field and the one most often missing. If four jobs share a key, the log shows the key and not the job, and no amount of retention fixes that afterwards.

02
What the call actually did

Not only the API name but the scope of the effect: which records, which bucket, how many rows. Read operations matter here as much as writes, because exfiltration is a sequence of reads.

03
What the agent was reacting to

The ticket, the repository, the page or the message that produced the action. Without it, a prompt injection incident is indistinguishable from normal work in the log.

04
When the permission changed

Access changes are the events that make later actions possible. A log of actions without a log of grants cannot explain why an action succeeded.

IN AN INCIDENT

The five questions, and what answers them.

Every row is a question somebody will ask in the first hour. The third column is why they often go unanswered.

Question asked after an incidentAnswerable withUsually missing because
Which agent made this call?Per-consumer identityOne credential is shared by several jobs.
What did it reach?Effect scope in the logOnly the API name is recorded.
Why did it do that?The triggering inputAgent context is not logged at all.
When did it gain that access?Grant and role change logAccess changes live in a different system.
Is it still happening?Retention past the detection gapLogs rotate after 30 or 90 days.
PRACTICE

How to get there. Four steps.

Step one is not a logging change, and skipping it makes the other three cosmetic.

01Split shared credentials first

No logging change helps while four consumers share one identity. This is the step that makes everything after it possible, and it is a change to access rather than to logging.

02Log the effect, not only the endpoint

Record what the call touched. A line saying a query ran is far less useful than one saying which table and how many rows.

03Capture the triggering context

Where the agent framework supports it, keep the input that produced the tool call. This is the only field that distinguishes a steered agent from a working one.

04Set retention against the detection gap

Choose how long to keep logs by how long incidents typically go unnoticed, which is months. A 30-day window guarantees the answer is gone before the question is asked.

FAQ

Questions, answered.

Short answers on ai agent audit trail.

What should an AI agent audit trail record?

Which identity made each call, what the call actually affected, what input the agent was reacting to, and when the underlying permission was granted. The first and third are the two most commonly missing, and both are needed to tell a steered agent from a working one.

Why can we not attribute calls to a specific agent?

Almost always because several agents share one credential. The log faithfully records the credential, which is all it can see. Splitting the identity per consumer is the fix, and it has to happen before any logging improvement is worth making.

How long should agent logs be kept?

Longer than the time it typically takes to notice an incident, which published breach reporting consistently puts in months rather than days. A retention window shorter than that detection gap means the evidence expires before anyone looks for it.

See what your agents can reach. Before someone else does.

Book a demo and we walk through the access paths in an environment like yours.