An agent log can help explain a suspicious action and create a second copy of the data you were trying to protect. Full prompts, tool responses, request headers, and exception strings may contain credentials or customer documents.

Start with the question an investigator needs to answer. For an outbound message, that might be who initiated it, what approval applied, which recipient class was involved, and whether delivery occurred. Most of those facts do not require the complete message body.

Define events at the application boundary

Record decisions where the application enforces them. A model’s statement that it received approval is not an approval record. A generated summary of a tool call is not proof that the tool ran.

Use separate events for a proposed action, authorization decision, attempted execution, and confirmed outcome. Connect them with an operation ID generated by the trusted application. Keep model-supplied text out of identifiers used to join sensitive records.

Question Useful field Usually unnecessary
Which task acted? Task and actor IDs Entire conversation
Why was it permitted? Policy version and approval reference Raw credential or session cookie
What was targeted? Scoped resource ID or destination class Full document contents
What happened? Outcome and delivery reference Unfiltered provider response

The right fields depend on the system. A resource identifier can itself be sensitive, so protect the event even when no message text is included.

Select fields instead of dumping objects

Build each event from an explicit list of permitted fields. Spreading a request object into a logger lets newly added properties become new data disclosures without a logging review.

Validate field types, lengths, and allowed values before emission. Structured JSON reduces delimiter confusion, but it does not make arbitrary input safe or appropriate to retain. Error messages deserve the same treatment: an upstream exception may embed a URL, header, or document fragment.

Redaction can provide additional protection, but a few regular expressions cannot reliably identify every secret in free text. Avoid collecting the text when the event can answer the operational question without it.

Record facts independently of the model

Take actor identity from authentication, task identity from trusted job state, and timestamps from the application. Mark source provenance when a field is a model claim rather than an observed fact.

Distinguish “request denied,” “request attempted,” “provider accepted,” and “outcome unknown.” A network timeout belongs in the last category until reconciled. Labelling it as a failed delivery can make a later retry look safe when the first request already succeeded.

For long tasks, record the applicable policy revision and revocation state at execution. A log of the initial plan alone cannot explain a later action under changed permissions.

Protect the evidence store

Keep write access separate from the identity being reviewed where possible. An agent that can alter its own authoritative audit history can erase the evidence of a boundary crossing. Central collection and controlled retention can help, but their guarantees need verification too.

Restrict who may query events, especially across tenants. Set retention according to investigation needs and applicable obligations instead of retaining everything indefinitely. Include backups, exports, and support tooling in that decision.

Hashing a low-entropy value is not reliable anonymization: an observer may guess candidate values and compare the hashes. Prefer avoiding unnecessary values or using a carefully designed pseudonymization scheme when correlation is genuinely required.

Test what is retained and what is missing

Use synthetic events containing obvious fake secrets, long strings, and newline characters. Verify the stored record, not just the logger call. Check that required IDs remain available and unauthorized viewers cannot retrieve another tenant’s events.

Also test the failure path when the logging destination is unavailable. Decide which high-impact actions must stop without an audit record and which may continue with a bounded local queue. Document that decision; silently dropping evidence is an operational behavior, not an implementation detail.

An agent security test plan should include the evidence pipeline itself. A useful log preserves the facts needed to review an action while keeping unrelated private material out of the investigation system.