Agent security
AI Agent Audit Trails: What to Record Before and After a Tool Call
Separate requests, proposed calls, decisions and observed effects so an investigator can reconstruct consequential agent work.

Executive summary
An AI agent audit trail should connect the person requesting work, the task, the proposed operation, the applicable policy decision and the observed result. Keep those events correlated while preserving their different meanings. A record that a call was permitted does not establish that it executed successfully; a tool response does not always establish its final effect. Store useful evidence with appropriate access controls and remove sensitive content the investigation does not need.
Begin with the question the record must answer
A staging database changed during an agent session. The team has a chat transcript and a successful command message. Neither identifies which account performed the change or whether staging was the intended target.
A useful audit trail lets an investigator follow the chain without reconstructing it from screenshots. Who initiated the work? Which agent and identity acted? What resource was selected? What decision preceded the operation? What did the destination report afterward?
These questions are related but belong to different systems. The agent may know the task, an action control may know its decision, and the database may own the authoritative change event. Plan the joins between those records before an incident requires them.
Keep four moments distinct
Record the request, proposed call, security decision and observed effect as separate moments. An investigator should be able to tell which one a timestamp describes.
| Moment | Useful evidence | What it does not establish alone |
|---|---|---|
| Request | Initiating user, task reference, approved scope | That every later operation matches the task |
| Proposed call | Tool, selected resource, relevant sanitized arguments | That the call executed |
| Decision | Outcome, policy version, applicable reason | That the destination reached the expected state |
| Observed effect | Tool result and independent resource evidence | That the operation was properly authorized |
For a blocked transfer, the expected destination observation may be that no fixture content arrived. For a permitted deployment, check the intended environment and release identity. Preserve an explicit unknown when the evidence cannot settle the effect.
Our security regression-suite article uses this separation in grading. The same discipline improves production investigations: avoid promoting an intermediate event into proof of the whole workflow.
Correlate identities and sessions
Keep an initiating user distinct from the identity used to access a resource. An agent can perform work through a service identity, an application token or another credential. The person who requested the task and the account that changed the database are not interchangeable fields.
GitHub's agentic audit-event reference illustrates that separation with agent indicators, initiating-user information and session identifiers. Its documented availability and event types have their own scope; do not assume another product emits identical fields.
Use stable references to join the records your systems actually provide. Include the agent and integration version where a change could affect interpretation. Record the resource's identity carefully enough to distinguish similarly named staging and production targets.
Keep missing fields visible. Inventing a user or session association because two timestamps are close can make the investigation less reliable. Where the join is an inference, label it and retain the evidence used to make it.
Record when an event occurred and when the collector received it. A delayed export can otherwise look like an action taken after containment. Preserve the source timezone or normalize timestamps with that information retained. When events arrive out of order, join them through reliable task and call references instead of silently sorting away the uncertainty. An investigator should be able to explain both the apparent sequence and the limitations of the clocks and collectors that produced it.
Design a minimal record before capturing everything
Start with the questions an owner must answer. Then choose the smallest useful data representation.
The following is an illustrative event design, not a Harden export schema or an OpenTelemetry field specification:
{
"task_ref": "demo-task-42",
"call_ref": "demo-call-07",
"actor_ref": "demo-service-identity",
"target_ref": "staging-fixture",
"decision_ref": "demo-decision-07",
"policy_revision": "reviewed-policy-a",
"effect_check": "pending"
}
A later event should record the observed effect and its source rather than silently rewriting this pending state into a success. Add timestamps, evidence locations and access controls through the organization's logging design. References should resolve for authorized investigators without embedding credentials in the record.
GitHub's OpenTelemetry reference documents agent and tool spans for its shared Copilot runtime, while distinguishing that runtime from the VS Code Local harness. That difference is a useful warning against treating every agent trace as one universal schema. Check the actual client and collection configuration.
Make sensitive-content capture a separate decision
More content can make a record more revealing without making it more useful. Raw prompts, tool arguments and responses may contain source code, credentials or customer information.
For each field, ask what decision it supports, who needs access and how long it must remain available. A resource identifier or sanitized argument can sometimes establish the relevant fact without retaining the full payload. Preserve enough detail to distinguish the approved recipient from an unintended one.
Review content capture deliberately. The same GitHub telemetry documentation distinguishes routine metadata from optional content capture. An administrator should understand the selected behavior before exporting traces to another system. Do not assume that enabling telemetry authorizes every downstream use of its contents.
Keep access to the evidence store separate from the agent's ordinary working authority. Review collection errors, clock differences and retention gaps. A complete-looking dashboard can conceal a missing segment of the action path.
Where Harden evidence belongs
Harden's supported pre-execution check concerns a proposed action before it runs. Its decision evidence is one part of the workflow record. Verify the fields available through the customer's actual configuration, then correlate them with the executing tool and destination.
A blocked-call record and an unchanged resource can support a useful conclusion together. Neither should be described as evidence that every possible transfer path was covered. The published research examples explain the action boundary without establishing a universal event-export contract.
For an evaluation in Control, select one consequential task and identify the evidence needed at each moment. Ask another engineer to reconstruct it using the retained records. The gaps they encounter are the collection work to prioritize.
FAQs
Is a chat transcript an audit trail?
It can supply useful task context and agent output, but it may not identify the actual executing account or authoritative resource state. Combine it with relevant tool, decision and destination evidence. An agent's statement that work succeeded should not be the only verification.
Should we record every tool argument verbatim?
Decide based on the investigation need and data sensitivity. Arguments may contain secrets or private material. Prefer sanitized values and stable references where they preserve the required distinction. Restrict access and retention for any necessary content capture.
Does a block event prove no data left the system?
It concerns the covered operation and recorded decision. Check earlier activity, alternate routes and the receiving system before making a broader conclusion. Record the scope of the observation rather than treating one intervention as proof about the entire session.
Can we use one event schema across agents?
You can define common investigative questions and normalize supported fields. Preserve the original source, client version and meaning of each field. Different agents and runtime configurations may expose different events; missing information should remain missing rather than being invented during normalization.
Who should own the audit trail?
Give collection reliability, access and retention explicit owners. The engineering team understands execution paths, security defines investigative needs, and resource owners validate effects. Rehearse a representative reconstruction so those responsibilities work together before an actual incident.


