Best practice · Agent orchestration
Record Enough of an AI Run to Debug It Without Logging Everything
Choose useful event records, protect sensitive inputs, and make failures traceable without dumping full conversations into shared logs.
An AI task fails and the activity panel says something went wrong. Someone proposes logging every prompt, file, and response so the next failure will be easier to diagnose. That can create a different problem: a broadly accessible archive of customer information and credentials. Useful diagnostics begin with the questions you need the record to answer.
Decide what a reviewer must reconstruct
For a routine workflow, a reviewer may need the task identifier, instruction version, tool name, start and finish times, result status, and a reference to the output. Those fields can show where work stopped without copying the entire source document into each event.
Give related events a shared run identifier. A fictional proposal workflow might include source loaded, draft saved, review requested, and export failed. The shared identifier lets someone follow the sequence even when several jobs are running at once.
Distinguish an attempt from a confirmed result
Record when an action was requested and when the destination confirmed it. An attempted send does not prove delivery. A timeout does not prove that the destination did nothing. Keep the provider receipt or destination record identifier when it is available and appropriate to retain.
This distinction supports safer recovery. The operator can check the confirmed state before repeating an action. A single red or green badge for the entire run often hides partial success that matters to the next decision.
Keep sensitive content in its proper place
OWASP's logging guidance describes useful event attributes and warns against recording sensitive information indiscriminately. Apply that by storing references to protected source records where possible and restricting access to diagnostic detail.
Do not place API keys, session tokens, or unnecessary personal data in ordinary activity messages. If a specific investigation requires a payload sample, use a controlled process with appropriate access and retention. More detail should be a deliberate diagnostic choice, not the default consequence of turning on verbose mode.
Make the failure message actionable
A useful message names the failing step, the relevant non-sensitive identifier, and what the operator can check next. Export failed after draft was saved tells someone where to begin. Unknown error beside a long unstructured transcript still leaves them searching.
Include instruction and configuration versions so a reviewer can distinguish a new failure from a change in behavior after an update. Avoid assuming that the same task title means two runs used identical inputs or settings.
Test the record during a controlled failure
Cause a harmless failure in a test environment and ask another person to explain what happened using the recorded events. If they cannot identify the last confirmed result, improve the event structure before collecting more content. Finish by checking who can view the records and when they are removed. A good run history helps the next person recover work without becoming an unnecessary copy of everything the business knows.