(Note · · 5 min read)
After an agent does something wrong, can you say what it did?
The question after any incident involving an agent is the same, and it is asked by someone who is not a developer: what did it do? If the honest answer is that the logs show a request came in and a reply went out, the incident has no floor, and you cannot say the problem is contained.
By Md. Habibur Rahman Shohel, full-stack & AI product engineer in Dhaka
Log the calls, not the conversation
Keeping transcripts feels like record-keeping, but a transcript tells you what was said, not what was done, and it is the doing that has consequences. Record every tool call as a structured event: which agent, acting for which user, called which tool, with which arguments, at what time, with what result.
Structured means queryable. The question is never show me the logs; it is show me every write this agent made to that account in the last six hours, and plain text cannot answer it under pressure.
Carry an identity through the whole chain
Give the agent its own identity rather than reusing the application's credentials, and attach the human it is acting for. Without both, an action is indistinguishable from the rest of the system's traffic and nobody can answer whether it was authorised.
Where one agent calls another, carry a single identifier for the whole run through every call. Multi-step work produces fragments across services, and without that thread you cannot reconstruct the sequence that led somewhere bad.
Keep what would hurt to lose, and redact what would hurt to keep
Problems surface late — a customer notices next month. Retain long enough to investigate something discovered after the fact, which is longer than most default retention.
At the same time, arguments contain whatever the model was handed, which may include personal data. Redact at the point of writing rather than hoping nothing sensitive passes through, exactly as you would keep personal data out of application logs and traces.
Record refusals too
The calls that were blocked matter as much as the ones that succeeded. An agent repeatedly attempting an action it is not permitted is the clearest early signal you will get, whether the cause is a bug, a bad prompt or injected content, and it is invisible if you only log successes.
Alert on the shape, not the volume: a refused irreversible action, a sudden burst of outbound calls, the same tool failing repeatedly in a loop.
The test
Pick an action your agent can take and ask whether you could answer, for last Tuesday: did it happen, who asked for it, what arguments were used, what came back, and was anything else attempted and refused. If any part needs a guess, the logging is not finished — and the time to find that out is not during the incident.
Common questions
What should an AI agent's audit log contain?
Every tool call as a structured event: which agent, acting for which human, called which tool, with which arguments, when, and what the result was. Transcripts record what was said rather than what was done, and it is the doing that has consequences.
Why does an agent need its own identity?
So its actions can be distinguished from the rest of the application's traffic and attributed to the person it was acting for. Reusing the application's credentials makes it impossible to answer whether a given action was authorised.
Should failed or blocked agent actions be logged?
Yes, and they are often more informative than successes. An agent repeatedly attempting something it is not permitted is the earliest signal of a bug, a bad prompt or injected content, and it is invisible if only successful calls are recorded.
How long should agent logs be kept?
Long enough to investigate something discovered after the fact, which is usually longer than default retention, since problems surface when a customer notices weeks later. Redact personal data at the point of writing rather than retaining it by accident.