An agent reply never shows its work, so an audit trail has to be built: one JSON line per tool call, with the time, the tool name, the arguments and the result. When a user questions an answer, the trail shows exactly what the agent did.
Before you start
You need an agent whose tool calls you can intercept, for example in the runner code or a LangGraph node. Decide the fields first: time, run ID, tool name, arguments and result are enough, and secrets must never be logged.
Write one JSON line per tool call
Add a logging step that runs on every tool call and writes one JSON line with the time, the run ID, the tool name, the arguments and the result. Keep the arguments short: log the values the tool used, not the whole conversation. Store the lines in a file the team can read, not in the agent reply.
Check a past answer against the trail
Pick one answer from last week and find its tool calls in the trail. Check each fact in the answer matches a tool result. If a fact has no matching call, the agent guessed it, and the trail has done its job by showing that.
Worked example: Three log lines for a fictional support agent
Northwind Support is a fictional help desk. Its agent logs every tool call. The table shows three lines.
| Time | Tool | Arguments | Result |
|---|---|---|---|
| 09:02 | order_lookup | order_id 1042 | Out for delivery |
| 09:03 | order_lookup | order_id 1043 | Delivered |
| 09:05 | calculator | 48 + 36 | 84 |
Expected result (UNTESTED): the three calls are in the log with their times, arguments and results, and the 09:02 reply matches the out-for-delivery result. We checked the OpenAI Agents SDK guides, which describe tracing as the record of every step, but we did not write the log on this machine.
Limits
A log is only useful if someone reads it: set a weekly review, or the trail grows unread. Never log secrets, API keys or personal data, and keep the log file access-controlled, because it records what the agent did with your data.
