Audit Logging for AI Agent Actions

AI agents don't just call APIs. They make judgment calls, and that's the whole problem with logging them. A regular app logs what happened. An agent needs to log what happened, why it happened, and who's on the hook for it. I've watched teams try to bolt compliance onto agent systems after the fact more times than I'd like, and it never once goes the way they hoped.
What makes agent behavior fundamentally harder to log than API calls
An API call takes an input and returns an output. An agent works differently: it's making a string of small, probabilistic decisions, and each one nudges its internal state in a direction that changes what it picks next. Log those decisions one at a time, disconnected from each other, and you get a pile of facts with no story holding them together.
Multi-step tool chains make it worse. Something as ordinary as "reconcile this month's invoices" can spin off a dozen intermediate decisions before anything visible comes out the other end, and auditors want the reasoning that got there, not just the final answer. That reasoning is the kind of thing you catch the moment it happens or you lose it for good; there's no photographing it after the fact.
Engineering teams try anyway, bolting a logging layer onto a system that was never built to produce this kind of evidence. It doesn't fix anything. It just logs the absence with more precision than before. If the execution model never generates the reasoning in the first place, no amount of wrapping and instrumenting afterward conjures it into existence.
The specific fields an agent audit log entry must contain
"Agent did a thing" tells you almost nothing. So what actually has to be in there?
Start with the mechanics: which tool got called, what parameters went in, what came back. Then the reasoning, meaning why this action out of however many others were sitting on the table. Then the blast radius: which files, which database rows, which external systems got touched. Where the model exposes its intermediate reasoning steps, write those down whole. Don't paraphrase them into a headline.
Outcomes carry as much weight as actions. Success or failure, the business context behind the call, any guardrail that tripped, any override a human applied on top of it. And if a person did step in, the log needs their identity, a timestamp, the risk flag that triggered review, and whether they accepted, rejected, or escalated the thing.
Access control gets skipped more often than teams would admit to. Which policy or RBAC role actually authorized this action? Leave that field blank and a post-incident privilege review turns into guesswork dressed up as forensics. Round it out with a snapshot of system state, model version, config, environment at that exact moment, plus the operational numbers engineering already tracks anyway: latency, error rate, token count, cost, drift signals.
Every entry needs, at minimum, a timestamp, the agent's identity and role, the context behind the call, and a rationale field. Miss one of those four and what you've built is a timestamp collection, not a provenance trail.
Agent identity as the precondition for any attribution
None of those fields mean anything without a clean answer to "who did this." Traditional software treats identity as the anchor for accountability. Agent systems skip that step more often than they should.
Five agents and three humans sharing one service account is a failure mode I've seen more than once. Something breaks, every log entry points to the same generic identity, and incident response turns into archaeology. Nobody can say which agent, or which person overriding which agent, actually pulled the trigger.
Two separate questions hide in that mess, and they need two separate answers. Which autonomous process performed this sequence of actions? That's agent identity. Which person or role authorized it? That's human identity. You need both. One without the other gets you a fingerprint with no suspect, or a suspect with no fingerprint.
The fix is easy to say and genuinely hard to enforce: give every agent its own identity, its own lifecycle, its own scoped permissions, its own way of proving who it is, instead of a shared password sitting in a config file that six processes all call home to. Skip that step, and even the best-written reasoning log in the world tells you what happened without ever telling you who did it.
How delegation chains in multi-agent systems break attribution unless every handoff is logged
Multi-agent systems add a wrinkle nobody enjoys: agents hand tasks off to other agents. Every handoff crosses an identity boundary, and miss logging even one of those handoffs, that's the exact seam where attribution comes apart quietly, without announcing itself.
The handoff record needs more than "this happened." It needs the scope of authority that moved along with it. Did the sub-agent get read access, write access, budget authority, or all three at once? Decision provenance ties each agent's actions back to whatever triggered them, and that's the only way to walk the chain backward later, agent by agent, without guessing at the middle steps.
A number from an industry incident writeup keeps coming back to me: a single compromised agent poisoned a large majority of downstream decisions within a handful of hours. Most incident response teams are still hunting for the right Slack channel at that point.
What that tells you: without a complete inter-agent log, damage spreads invisibly, and by the time anyone starts a forensic review it's already everywhere. Controls that check an action before it fires catch what after-the-fact log analysis never will, because forensics only tells you what already burned down. In-path controls can stop the fire from spreading room to room in the first place. Every agent-to-agent message, every handoff, every state change needs to be its own logged event, not some internal detail nobody thought was worth exposing.
Making the log itself trustworthy: tamper-evidence and immutability
Here's an uncomfortable fact: when an agent moves money or deletes a file, there's usually no human watching it happen live. The log is the only witness in the room. If that witness can be edited after the fact, the whole accountability story collapses, because now you're trusting a record that might've been rewritten by the very thing it's supposed to be watching.
Two mechanisms, used together, make a log actually trustworthy. WORM storage (write-once-read-many) at the infrastructure layer means entries physically can't change once they're written. Cryptographic hash chaining at the log layer means every entry's hash depends on the one before it, so altering anything in the past breaks every hash downstream of it. Pull one block out of that chain and the whole structure visibly leans.
Each agent should sign its own entries too, adding authenticity per record on top of the chain's overall integrity. Route everything into a SIEM sitting outside the agent's own reach, so it physically can't edit or delete the record of its own behavior. That one step closes off a pretty obvious attack surface, and it's cheaper than people expect.
Teams stand up the hash chain, feel good about it, and never check it again, and that's where this breaks in the real world, constantly. An unverified chain is a smoke detector with no battery; you find out it's dead exactly when you need it to work and it doesn't. Run a nightly automated job that checks the chain and screams if it finds a break. Not quarterly. Not "next sprint, probably."
Some experimental multi-agent architectures are toying with anchoring task identities and state transitions to a blockchain via Merkle proofs, a "ledger layer" of sorts. Interesting direction, still firmly in research territory, and I wouldn't build a compliance program around it yet.
Where PII and secrets belong — and where they do not
Immutability cuts both ways. It protects your log's integrity, and it also permanently locks in whatever garbage you happened to write to it. PII in an append-only log isn't a temporary exposure you clean up next quarter. It's permanent, written in marker on a wall you can't repaint.
The rule I'd put on that wall instead: log what happened, not the data that happened to it. Resource IDs, action types, outcomes, policy references, all fine. Raw PII, customer names, social security numbers, API keys: none of it belongs anywhere near the log.
The EU AI Act's Article 12 crosses paths with GDPR right here. A cryptographic hash of the input, paired with classification and policy metadata, satisfies the logging requirement on its own in most regulatory readings I've seen. Storing the prompt body in cleartext buys you nothing except a second compliance headache under GDPR that you didn't need and nobody asked for.
In practice, that means hashing or tokenizing identifiable values at the moment of logging, keeping the hash for correlation while dropping the underlying value entirely. Encrypt everything, in transit and at rest. Lock the full log away from the agent itself, and away from any role that doesn't strictly need to see it.
Secrets get the same treatment, just earlier in the pipeline. API keys and credentials passed as tool parameters need redacting before the entry gets written, never masked afterward, because once the record is sealed you can't reach back in and scrub it clean.
There's a real cost here, and it's worth saying plainly: strip out enough PII and secrets, and correlating entries across a session gets harder. The fix is a separate, access-controlled correlation index, one that lets you keep the redaction policy exactly as strict as it needs to be without losing the ability to trace a session end to end.
Why retrofitting audit logging to an existing agent system usually fails
Here's the blunt version: if the execution model doesn't produce structured evidence at each decision step while it's running, no amount of logging bolted on afterward brings that evidence back. That moment already passed, and it's not coming back for a second take.
Bringing compliance-grade audit trails to a system that wasn't built for them usually means rebuilding the execution model so it emits structured output at every processing node. That's a rearchitecture project. It is not a logging shim you knock out in a two-week sprint, no matter what the ticket says.
Which changes how teams need to buy and build in the first place. Audit logging needs a seat at the design-time table, right next to model choice and tool scope, instead of getting treated as an integration detail you'll "get to" after launch.
There's one partial fix if you're already in production: an eBPF-based sensor at the kernel layer can watch what the agent does, tool calls, model invocations, data reads, and emit structured events without touching a line of the agent's own code. Genuinely useful, and genuinely limited at the same time. It can tell you a tool got called. It can't tell you why, because that reasoning was never produced anywhere in the first place. It's a good security camera pointed at a room where nobody's taking notes.
For anyone building from scratch, decide what the runtime emits during the architecture phase, not six months after launch when someone finally asks whether you can prove what happened.
What the regulatory frameworks actually require operators to do
The EU AI Act (Regulation 2024/1689), Article 12, is the sharpest deadline on the table right now. Full application for high-risk AI systems lands August 2, 2026, and that window is closing faster than most compliance teams seem to realize. The Act requires automatic event logging across a high-risk system's entire lifecycle, with deployers holding logs for at least six months and producing them for surveillance authorities on request.
One detail catches people off guard every single time: buying a high-risk system from a vendor doesn't hand off the retention obligation along with the purchase order. The deployer stays on the hook no matter who built the underlying agent. Penalties run up to 15 million euros or 3% of global annual turnover, whichever is bigger, which tells you exactly which number regulators expect to actually get used. The technical standards are still catching up to the law; prEN 18229-1 and ISO/IEC DIS 24970 are both still in draft as of this writing.
On the US side, NIST's COSAiS project is building SP 800-53 control overlays for AI use cases, and it looks like it's shaping up to be the federal reference point for agent authentication, authorization, and audit logging. NIST has also been running sector sessions in healthcare, finance, and education around AI agent identity and authorization. Sector-specific overlay rules are coming. That's not a maybe, that's a when.
Strip away the jurisdiction and the acronyms, and every regulator lands on the same handful of requirements this piece has already walked through: identity linkage, decision traceability, retention, accessibility. They're just arriving there through legal mandate instead of engineering judgment. Build to the technical standard now, and the sector rules will probably find you already compliant. Build to the legal minimum, and you'll be retrofitting on somebody else's clock, at somebody else's speed.
How open-source agent platforms make audit logging observable and extensible by default
Closed agent platforms carry a structural problem in their audit story that no amount of vendor documentation papers over. If the execution model is proprietary, the operator can't see what evidence the agent generates at each decision point, can't verify the log is complete, can't extend the schema to catch something specific to their own business. You end up auditing a black box through whatever windows the vendor decided to cut into it for you.
Open-source platforms, OpenHands among them, take a different approach. The execution model is fully visible, so operators can see exactly which events fire, at which decision points, carrying which fields. There's no separate log layer sitting quietly on a vendor's infrastructure that you're just asked to trust.
Model-agnostic architecture matters here too. When the runtime isn't welded to one specific model, the model version, provider, and call parameters get logged as actual fields, instead of getting reverse-engineered from opaque API traffic after something's already gone sideways on you.
Deploy-anywhere infrastructure keeps the logs where the operator actually lives: routed into the operator's own SIEM, held under the operator's own retention policy, governed by the operator's own access controls, rather than sitting on someone else's servers in a format and on a schedule you have no ability to audit.
For anyone operating under Article 12, or whatever NIST eventually finalizes, this stops being a nice-to-have. Deployer accountability means the compliance obligation never actually transfers to the vendor, no matter what the contract implies it does. Log ownership becomes a direct regulatory concern, not a convenience you quietly trade away for a smoother onboarding call.
Extensibility rounds it out. An open codebase lets a team instrument new decision nodes, bolt on organization-specific metadata, or wire logging straight into an existing identity governance system, exactly the kind of customization compliance-grade logging tends to demand and closed platforms simply can't hand you, no matter how nicely they ask you to trust them.
So before signing on to any agent platform, ask the plain question: can you actually inspect every log entry the runtime produces, without asking anyone's permission first? If the honest answer is no, you already know where that road ends.


