When an agent does something strange, the natural thing is to ask it why. You will get an answer. It isn't the one you asked for.
Confabulated explanation
An account a model gives of its own behaviour, written as new text rather than read from a record. It may be right or wrong, and it reads the same either way. Asking "why did you do that" gets you a plausible story.
When an agent breaks something, its explanation isn't a log. Read what it actually did: the actions it asked for (tool calls, coming next), the results and the diff. Treat "why" as a source of hypotheses, then test them.
“Don't explain from memory. List the exact commands you ran this session that touched the database, in order, copied from the tool calls. Then we'll check them against the database logs.”