Building a flight recorder for AI agent tool calls
A chat transcript is a poor record of an agent run. The useful record is the tool call: what was asked, what the tool returned, and how that result fed the next step. The flight recorder I have been building is that record. It is not a claim that a failed run can be perfectly reproduced.
A call is useless without its run
A single tool result does not explain itself. It belongs to a run, and the run belongs to a task. I keep three ids on every record: the run, the call, and the parent call when one tool result caused another. Order is a timestamp plus a sequence number, because two calls can finish in the same millisecond and a clock is not an order.
The record stores the tool name, the input the agent actually sent, the output or the error, and when the call started and finished. I do not store a second, cleaned copy of the input. If the agent sent a bad argument, that bad argument is the thing I need to see later.
type ToolCallRecord = {
runId: string
callId: string
parentCallId?: string
name: string
input: unknown
output?: unknown
error?: { name: string; message: string }
startedAt: string
finishedAt?: string
seq: number
}Errors need the boundary, not a stack novel
The error I keep is the one the tool returned to the agent: a name, a message, and whether the failure happened before the tool ran, inside it, or after the result came back. A stack trace from my own process is useful to me and useless in the record the next reader sees. If the tool failed because a permission check refused the call, that refusal is the error. Hiding it behind a generic "tool failed" makes the timeline look like a model problem.
I also keep a status that is only one of: started, succeeded, failed, cancelled. A call that never finished stays started. I would rather show an open call than invent a success when the process died.
Replay is a view, not a second execution
The recorder can walk the timeline forward and show each call in order. That is the part a visitor can understand: a run can be inspected after it ends. What it cannot do is re-enter the live system and expect the same answer. A diary row may have changed. A token may have expired. A write that was approved once should not be approved again just because someone pressed replay.
So replay is read-only. It shows the stored input and output. It does not call the tool. If I need to try the call again, that is a new call, with a new id, and it goes through the same permission check as the first one.
Logs are a privacy problem
Tool inputs are where secrets land. A prompt, a customer name, a file path, an access token passed as an argument. I treat the record as production data, not as debug confetti. Credentials are not written into the record. If a tool needs a secret, the call stores that a secret was used, not the secret.
Personal data is harder, because the useful bug is often in the actual field. The rule I use is narrow: keep the fields required to understand the failure, drop the rest, and do not copy the record into a chat tool to "ask what went wrong." A flight recorder that leaks the workspace is worse than no recorder.
What I would not add yet
A diff of the whole workspace after every call is attractive and mostly noise. The call input and output already say what the tool claimed to do. A full snapshot is a second product, and it pulls in files the call never touched.
I also do not score the model from this log. The recorder answers what happened. An eval can be built on top of the same records later. Mixing a grade into the log makes people edit the log to improve the grade.
The timeline view is a list, not a graph. Each row is one call, indented when it has a parent. Selecting a row shows the stored input and output and nothing else. I tried a richer view that drew arrows between calls. It looked like a system diagram and hid the one fact that mattered, which call failed. A list with a sequence number is easier to trust, because the order on screen is the order in the record.