$ fssg build --deterministic --validate |

Observe AI Agents Without Logging Their Secrets

AI Engineering

The easiest way to debug an AI agent is to record everything. It is also one of the fastest ways to turn observability into a second, poorly governed copy of the system's secrets.

Prompts can contain customer data. Tool arguments can contain tokens, paths, queries, and document fragments. Tool results can contain more sensitive material than the model ever sees. If all of that flows into a tracing backend by default, the trace is no longer metadata about execution. It is another data store—with its own access, retention, export, and breach surface.

I use a stricter rule: the default trace should explain the shape and outcome of execution without reproducing its payload. Content capture is an escalation mode, not the foundation of observability.

Split the envelope from the payload

An agent trace needs a stable operational envelope. For each run and step, I want identifiers, timing, control flow, policy decisions, usage, and outcome:

{
  "run_id": "run_01K...",
  "step_id": "step_07",
  "parent_step_id": "step_03",
  "operation": "tool.call",
  "tool_name": "crm.update_contact",
  "policy_decision": "approval_required",
  "input_schema": "crm.update_contact@3",
  "input_bytes": 842,
  "status": "denied",
  "duration_ms": 41,
  "error_type": null
}

This record answers useful questions without storing a person's email address or the proposed CRM note. Which tool was selected? Which schema governed the call? Was execution allowed? How long did the gate take? Where did the branch end?

The payload is different. It contains prompt text, retrieved documents, tool arguments, tool results, model output, and sometimes system instructions. That material can be indispensable for one investigation, but it should have a separate policy, destination, retention period, and access path.

This distinction also keeps telemetry meaningful. I have already argued that trace identity and trace meaning need an explicit compatibility contract. Payload separation adds another boundary: a schema migration must not silently turn metadata-only spans into content-bearing records.

A useful trace has four layers

I design the trace from the least sensitive layer upward.

Layer Record by default Typical use
Execution run/step IDs, parent links, operation, timestamps, status reconstruct control flow
Decision policy result, approval state, selected tool/model class explain why a transition occurred
Resource token counts, duration, retries, bytes, cache status cost and performance analysis
Content prompts, arguments, results, retrieved text narrow forensic debugging

The first three layers should solve most operational questions. Full content belongs in the fourth layer and should be opt-in.

OpenTelemetry's current GenAI conventions follow the same pressure gradient: model and operation metadata can be recorded without message content, while input messages, output messages, prompt variables, system instructions, tool definitions, tool arguments, and results are treated as sensitive or opt-in fields. The OpenAI Agents SDK exposes a similar control: tracing is enabled by default, while trace_include_sensitive_data controls whether model and function spans include inputs and outputs.

Those defaults are useful, but framework switches are not a complete security design. Custom spans, application logs, exception objects, HTTP middleware, and exporter transformations can reintroduce the same payload. The contract has to cover the whole telemetry path.

Capture fingerprints, not replicas

When content cannot be retained, I still need enough evidence to correlate events. A small content descriptor is usually safer than a copy:

{
  "content_ref": "vault://incident/INC-2041/tool-input-07",
  "content_hmac": "hmac-sha256:9b4...",
  "content_class": "customer_record",
  "redaction_policy": "pii-v4",
  "retained": false
}

A keyed digest can show that two systems observed the same normalized payload without making low-entropy values easy to recover by guessing. A plain hash is not enough for fields such as email addresses, phone numbers, or small enumerations. The HMAC key must live outside the telemetry backend, and the normalization rules must be versioned.

content_ref should point only to an approved evidence store. It must not become a convenient permanent archive. If a payload is retained for an incident, attach a reason, owner, expiry, and deletion path. If it was not retained, say so explicitly rather than emitting a reference that cannot resolve.

Make diagnostic escalation a bounded operation

“Enable debug logging” is too broad for an agent that can touch many users and tools. I prefer a capture lease:

capture_lease:
  scope:
    run_id: run_01K...
    tool: crm.update_contact
  fields: [tool_arguments, tool_result]
  reason: INC-2041
  approved_by: security-oncall
  expires_at: 2026-09-17T09:00:00Z
  destination: restricted-forensics

The lease answers five questions before content leaves the process: which run, which operation, which fields, for what reason, and until when. The exporter should reject content outside that scope. Expiry should be enforced by the collector or storage policy, not remembered in a ticket.

For failures that cannot be reproduced, this gives operators a controlled way to collect evidence. For ordinary runs, the system returns to metadata-only mode automatically. That is much safer than a global environment variable left enabled after an incident.

Test the absence of data

Observability tests often prove that required fields exist. Privacy requires the inverse test as well: forbidden material must not exist anywhere downstream.

A practical CI test can inject canary values into every content surface:

  • a fake secret in the system instruction;
  • a synthetic email in the user message;
  • a canary token in tool arguments;
  • a unique marker in the tool result;
  • a marker inside an exception message.

Then export the trace through the real collector configuration and scan the serialized output. The test fails if any canary appears outside the approved encrypted fixture. This catches leaks in automatic instrumentation, custom spans, error serialization, and exporter processors.

The same principle belongs in the runtime itself. An AI engineering runtime should own the telemetry policy at the execution boundary, because the model cannot reliably decide what is safe to log. The final run artifact can describe what happened without becoming a transcript; an execution artifact and a trace have different jobs.

What this design does not solve

Metadata can still be sensitive. Tool names may reveal business processes. Stable identifiers can enable correlation. Token counts and timing can expose usage patterns. Redaction can remove evidence needed for an investigation, and HMAC correlation is only as trustworthy as its key management and canonicalization.

So the boundary is not “metadata safe, content dangerous.” It is: collect the minimum evidence for a declared operational question, classify every field, and make richer capture explicit, narrow, and temporary.

A trace should let me reconstruct authority, sequence, cost, and failure. It should not quietly reconstruct the user's private world.

Sources

FACET AI CLI Terminal
facet@ai:~$