Agents will explain what they did. That explanation is generated text. The behavior is tool calls. These will not always match. Sometimes by accident. Sometimes because the agent was instructed to misrepresent its reasoning. Either way, the explanation is theater. Log every tool invocation at the framework layer so nothing goes unrecorded, and apply the same observability discipline you brought to your API server in 2014.
// Wrap the tool layer. The agent's narrative is not the record.
function auditedTools(tools: ToolMap, ctx: TraceCtx): ToolMap {
return Object.fromEntries(
Object.entries(tools).map(([name, fn]) => [
name,
async (input: unknown) => {
const output = await fn(input)
// Immutable append-only record. Not a log you can edit.
await trace.record({
agentId: ctx.agentId,
tool: name,
input,
output,
traceId: ctx.traceId, // link to parent span
ts: Date.now(),
})
return output
},
])
)
}
// The explanation is a story. The trace is the evidence.
The explanation is a story. The trace is the evidence.