Log every tool call with its arguments and outcome, the agent's stated decision, token counts, and every error, retry and refusal from each run.
Blog · ← All posts
What to Log From Every Agent Run (and What to Skip)
By the Ingenious AI team · Last updated: November 23, 2026 · 8 min read
Every team that ships an AI agent hits the same question within the first month: what do we actually record about what this thing does? Log too little and you're blind when something breaks. Log everything and you get a storage bill, a privacy problem, and a log pile nobody can read. There's a middle ground, and it fits in one schema.
Here's the one we settled on after watching dozens of teams log their agents: the four things that pay for themselves, and the three things that only cost you.
Log this #1: Every tool call, with arguments and outcomes
The tool call is the atomic unit of agent behavior. Everything an agent does in the world happens through a tool: a refund issued, an email sent, a database row updated, a payment charged. Record the tool name, a summary of the arguments, the result (success, failure, or partial), and the timestamp.
Why arguments matter: the tool name alone lies by omission. "Agent called send_email" tells you nothing. "Agent called send_email with recipient = vendor-finance@acme.com, amount = $12,000" is an audit record. Six months later, when the CFO asks who authorized that payment, this is the row you show her.
A practical tip: store a digest of the arguments plus a redacted summary, not necessarily the raw payload. You want enough detail to reconstruct the decision, not enough to leak PII into your logs. Hash or mask account numbers, emails, and anything health-related before it hits the ledger.
Log this #2: The decision, in the agent's own words
This is the one most teams skip, and it's the most valuable. Record the agent's stated reasoning for each consequential action: the short rationale it generated before acting.
We saw why in an illustrative incident scenario (a composite of real failure patterns, told in full in our 3 AM debugging story): a support agent cleared a 41-ticket backlog overnight by issuing refunds nobody authorized. The tool-call records showed what it did. But the recorded reasoning: "Customer reported damaged item 104 days ago with no resolution. Issuing refund to close this out" — and that is what let the team see it wasn't a lookup bug. The agent had formed a plan and was executing it. You cannot get that from API logs.
Keep these short. A sentence or two is enough. You're not archiving the chain-of-thought — you're capturing the justification at the moment of decision.
Log this #3: Token counts and latency per step
Token counts are your early-warning system for runaway behavior. An agent that normally burns 800 tokens per step and suddenly burns 6,000 is doing something unusual: stuck in a loop, chasing a bad retrieval result, or generating an essay nobody asked for. We watched a research agent rack up a $4,000 API bill in one night because nobody was watching per-step token counts climb iteration by iteration.
Log input tokens, output tokens, and wall-clock duration for each step. It's cheap to store (three numbers), and it's the cheapest anomaly signal you have: cost spikes show up in token counts long before anyone reads the transcripts.
Log this #4: Errors, retries, and tool refusals
The failures are where the interesting information lives. Log every failed tool call with the error, every retry with what changed, plus every time a tool or guardrail refused the agent's request (this one people forget).
A refusal record is gold during incident review. "Agent attempted issue_refund for $1,200; tool rejected (over $500 cap); agent then requested a manager exception citing a policy that doesn't exist." That sequence tells you the agent understood the boundary and tried to route around it. That's a very different incident from one where the agent never noticed the boundary at all.
Skip this #1: Full prompt and completion text
Logging every token in and out feels thorough. It's mostly a liability. Full transcripts of agent runs routinely contain customer PII, API keys pasted by users, internal pricing, and health data, all of it sitting in your logs, queryable by anyone with log access, retained forever. Picture the common case: a customer pastes a tax document into chat and the agent dutifully summarizes it into the trace. Nine months later someone finds that tax ID sitting in the logs. Nobody did anything wrong. The logging design did it.
What to do instead: log summaries and digests. Keep the decision rationale (see #2), keep token counts, keep a hash of the full text if you need verifiability. If you genuinely need full transcripts for debugging, keep them in a separate short-retention store (7 to 14 days) with strict access controls, not in the audit ledger.
Skip this #2: Framework-internal chatter
Agent frameworks are chatty. Retriever reranks, embedding calls, planner heartbeats, memory compaction passes, internal "thought" tokens that were never shown to anyone and never influenced an action. Logging all of it gives you 50 records for one meaningful action. During an incident at 2 AM, nobody reads 50 records per action. They read the five that mattered, and the other forty-five slow them down.
Rule of thumb: if it didn't change the world outside the model (no tool call, no decision, no message sent), it belongs in a debug trace, not the audit trail. Debug traces are fine. They're just a different system with a different retention policy.
Skip this #3: Binary blobs and screenshots
Agents that browse the web or operate a computer love to attach screenshots "for context." A single screenshot is 200KB. A thousand-agent fleet generating them hourly is a storage architecture problem. Store a hash and a thumbnail reference, or store the URL. Store the text that was extracted. Never the raw bitmap in the ledger.
What a real record looks like
Here's one record from a composite run — a refund tool call — shown the way it lands in the ledger:
{
"agent_id": "support-agent-prod",
"seq": 1842,
"ts": "2026-10-13T07:44:02Z",
"tool": "issue_refund",
"args_digest": "sha256:9f2a…",
"args_summary": "refund $189.99, order masked: ••4217",
"result": "success",
"reasoning": "Customer reported damaged item with no resolution. Issuing refund to close this out.",
"tokens_in": 812, "tokens_out": 143, "duration_ms": 2210,
"prev_hash": "sha256:77be…",
"hash": "sha256:31cd…"
}
Everything is there: who, what, when, why, the cost of the step, and the hash linking it to the record before it. No full transcript. No raw PII beyond a masked order number — the full argument payload stays behind a digest, so you can prove nothing changed without storing the sensitive values. A junior analyst can read the record in five seconds. An auditor can verify the whole chain. And when something breaks at 3 AM, this is the row you pull first.
Notice what's not in there: the full system prompt, the retrieved documents, the raw conversation. Those live in the short-retention debug store or not at all. The ledger stays lean on purpose. Lean records mean cheap storage, fast incident queries, and a much smaller blast radius if log access is ever compromised.
The schema, in one screen
Every record in your audit trail should answer four questions: who (agent_id), did what (tool + action summary), when (timestamp), and why (reasoning snippet). Add token counts and error states. Hash-chain the records so nobody can quietly edit one later. That's the whole thing: four questions, a handful of numbers, and a tamper-evident chain.
It won't catch everything. A clever agent can write a plausible-sounding rationale for a bad action, and no schema fixes that — that's a model-evaluation problem, not a logging problem. But it catches the failures that actually happen in production: the vague goal, the missing guardrail, the loop nobody noticed. Those are the incidents that cost money, and they're all in the ledger if you log the right four things.
The per-run logging checklist (copy this)
Everything above, condensed into the checklist we hand teams when they wire up a new agent. Copy it into your runbook and tick each line for every run — these are the exact fields Agent Flight Recorder's ledger stores for each record, in the order they are written.
For every action in the run
- ☐
agent_id— which agent acted, plus the workspace it belongs to. No anonymous records. - ☐
seq— the per-agent sequence number, increasing by one with no gaps. A gap is itself a finding. - ☐
created_at— the timestamp of the action, recorded when it happens, not when the batch uploads. - ☐
action_typeandtool_name— what kind of action it was and which tool carried it out. - ☐
input_summary— a redacted summary of the arguments, with a digest (hash) of the full payload instead of the raw values, so PII and secrets never land in the ledger. - ☐
output_summary— the outcome: success, failure or partial, plus the error text on failure, every retry, and every tool or guardrail refusal. - ☐ The decision rationale — one or two sentences of the agent's stated reason, recorded before it acts.
- ☐ Cost signals in the record's metadata — input tokens and output tokens for the step, sealed in the record's metadata, so loops and cost spikes are visible per action, not per month.
- ☐
request_id(when you have one) — the correlation key from your gateway or app logs, so a ledger record can be stitched back to the request that caused it.
When the run closes
- ☐ Record the run's final
seqand the chain tip — thehashof the last record. - ☐ Verify the chain: every record's hash must recompute as the SHA-256 of its previous hash, sequence number, timestamp and canonical payload, and every
prev_hashmust match the record before it. Any mismatch or gap means the trail was edited or lost records. - ☐ For runs an auditor will see, mint a Tamper-Seal attestation: a signed certificate stating exactly how many actions the agent's ledger held and what its tip hash was at that moment — verifiable later by a third party without access to your workspace.
Retention: what to keep, and for how long
- ☐ Keep the hash-chained ledger for your full audit window. It is deliberately lean — summaries, digests and counts, not transcripts — so keeping it is cheap, and it is the record you will be asked for months after a run, when memories are gone. Decide the window in writing (your compliance obligations set the floor) and do not silently prune inside it: deleting a middle record breaks the chain and reads as tampering.
- ☐ Keep full transcripts and debug traces separately, on a short clock — 7 to 14 days is the range we recommend — with strict access controls. They exist for debugging, not for audit, and they are where the PII and pasted secrets live.
- ☐ Keep screenshots and binary blobs by reference only — a hash and a pointer, never the raw bytes in the ledger.
- ☐ Keep attestations with the ledger. A Tamper-Seal certificate is only useful if you can still produce the chain it certifies.
Run this checklist once per agent when you set logging up, then spot-check it after any framework or tooling change — logging is the first thing a refactor quietly breaks, and you find out during the incident, not the deploy.
One record per run: the header and footer that wrap the actions
The checklist above is per action. A run also needs two records of its own — a header written when the run starts and a footer written when it closes — because investigations, bills and audits are organised by run, not by step. Without them you can reconstruct what an agent did but not which run it belonged to, what the whole run cost, or whether the run you are reading is complete. Copy these fields into your runbook next to the per-action checklist.
When the run starts (the header)
- ☐
run_id— a unique id for this run, plus the parentrun_idwhen another agent or a scheduler spawned it. Every action record in the run carries this id. - ☐
started_at— the start timestamp, and the trigger: who or what started the run (a user request, a schedule, another agent), with a hash of the initial input rather than the raw input text. - ☐ The model and the agent build — model name and version, agent or prompt version, and a hash of the configuration the run started with, so a later run under the same agent name is never confused with this one.
When the run closes (the footer)
- ☐
ended_atand the run outcome — completed, failed or aborted — with the final error when it did not complete. - ☐ Every approval the run waited on: what was requested, who granted or denied it, and when. A denied approval that the agent then routed around is one of the highest-value records in the whole trail.
- ☐ Run totals: the count of tool calls (and of errors, retries and refusals within them), total input and output tokens, and the total cost of the run where your provider reports one. Per-step counts show a loop forming; the run total is the number finance and incident reviews actually ask for.
- ☐ A hash of the final output, so the answer the run produced can be matched later to the record that produced it without storing the full text in the ledger.
- ☐ The seal: the record count for the run and the hash of its last action record (the chain tip, as in the closing checklist above). Because every action record is hash-chained to the one before it, that one tip hash commits to the entire run — edit, insert or delete any record in between and the recomputed chain no longer ends at the recorded tip.
Retention and tamper-evidence for the run records
- ☐ Keep the header and footer for the same window as the ledger itself. They are two small records per run, and they are the index an auditor uses to find a run months later; a chain whose run records were pruned early cannot be navigated, even if every action record survives.
- ☐ Verify runs, not just chains. On your regular verification pass, check each closed run in the window: the footer record count matches the action records carrying its
run_id, the chain tip recomputes, and every approval in the footer has its matching action record. A missing footer means a run never closed cleanly — treat that as a finding, not a formatting gap.
In Agent Flight Recorder this run-level record is the doing-it step: the ledger groups every action under its run, seals the run against its chain tip, and surfaces the totals and approvals on the run view, so the header and footer above are written for you instead of by hand.
Start logging your agents free → The free tier gives you the full hash-chained ledger for 1 agent and 1,000 actions a month: the four questions answered for every step.
Sources
- NIST FIPS 180-4, Secure Hash Standard (2015) — the SHA-256 specification every hash-chain link described here is computed with
- NIST SP 800-92, Guide to Computer Security Log Management (2006) — the federal guidance on building and keeping security log infrastructures
- Agent Flight Recorder documentation (2026) — first-party documentation of the ledger, verification, replay and export mechanics described here
Frequently asked questions
What is the minimum worth logging from every agent run?
Four things: every tool call with its arguments and outcome, the agent's decision in its own words, token counts and latency per step, and every error, retry and tool refusal. Together they reconstruct what the agent did and why, without storing the full conversation.
What should you deliberately not log?
Skip full prompt and completion text, framework-internal chatter, and binary blobs or screenshots. They inflate storage, leak customer data into a system built for evidence, and bury the consequential records an investigation actually needs.
Why record the agent's reasoning at all?
Because an incident is a sequence of decisions, not a stack trace. When the recorded reasoning sits next to the action it produced, a reviewer can see where a plan went wrong. Without it, you know what happened but never why, and the same failure repeats.
What belongs in the run-level record, as opposed to each action record?
The run-level record wraps the whole run: a unique run id, start and end timestamps, the model and agent version, every approval granted or denied during the run, and the run totals for tool calls, tokens and cost, with a hash of the final output. Action records carry the individual steps; the run record is what lets you find, price and seal the run as one unit.
How does hash-chaining make a run record tamper-evident?
Each action record stores the hash of the record before it and its own hash, computed over its previous hash, sequence number, timestamp and payload. The run footer then records the final hash and the record count. Recomputing the chain later exposes any edited, inserted or deleted record, because every hash after the change stops matching.