Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Log an agent run as a trace: a correlated record of the workflow’s model and tool steps. For each tool execution, capture its identity, arguments, result when available, timing, status, and useful error detail. Treat raw arguments and results as sensitive data: decide what to retain, redact or omit what you do not need, and restrict access to any retained content.

Model a run as a trace, not a pile of messages

A trace represents a workflow or agent turn; its spans represent individual operations within it. Nest model-generation and tool-execution spans under the agent or subagent that performed them. Parent-child relationships show which operation led to another, while timestamps and durations help explain ordering and latency. Parallel child operations can overlap, so a timeline is more informative than assuming every step happened sequentially.

Keep tool activity distinct from model prompts and completions. The model’s request and response help diagnose generation; the tool span records what the agent asked an external capability to do and what came back. OpenAI’s Agents API tracing guide describes tool span details including arguments, results when available, status, timing, and error information. For MCP calls, details can include the server label as well as the tool name, arguments, output, and error.

Choose fields that answer operational questions

A practical record can be a span or structured event. The following is an implementation synthesis, not a universal schema:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Correlation and ownership: trace ID, span ID, parent span, workflow or agent name, and the actual session or conversation identifier if the application has one.
  • Tool identity: tool name and, where applicable, server identity. Prefer a stable, low-cardinality identifier for grouping and analysis.
  • Execution timing: start timestamp and end timestamp or duration.
  • Outcome: success or failure status and a low-cardinality error type. Add concise error detail useful for debugging without unnecessarily copying sensitive payloads.
  • Call content: structured arguments and result when policy permits. Otherwise record a minimized or redacted representation, or a reference to separately controlled content storage.
  • Relevant state changes: retries, approval decisions, and other execution transitions when they explain what the agent did.

Use trace context to connect operations; do not treat a trace ID, newly generated UUID, or hash of request content as a substitute for a real conversation identifier. OpenTelemetry’s agent span conventions advise against inventing a conversation ID when the application has no genuine one.

Decide whether to record payloads

Tool arguments and results can contain credentials, personal information, proprietary data, or other content that should not be broadly available. Model instructions, prompts, and completions pose similar risks, but are different data from tool inputs and outputs. Establish a capture policy before enabling production logging, and retain only the content needed for the debugging, operational, or security purpose.

Omit content when metadata is enough

OpenTelemetry’s GenAI span conventions state: “Default: Don’t record instructions, inputs, or outputs.” A metadata-only trace can still preserve tool identity, timing, outcome, and error classification without retaining message bodies. Consult the current conventions when implementing, since these conventions can evolve.

Capture content selectively

If payloads are needed and permitted, redact or minimize them before they reach exporters and telemetry backends. Consider which fields are essential, whether values can be masked, and who can view the resulting records. A redaction mechanism is only effective if its failure behavior is understood and tested.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Store large or sensitive content separately

OpenTelemetry documents storing message content in external storage and placing references on spans. This separates access control and retention for payloads from telemetry metadata. The conventions note that message attributes can be large, may include media, and can exceed backend limits; they describe filtering or truncation and tuning batch/export settings when uploading content. For high-volume or sensitive production workloads, the external-storage pattern can reduce pressure on the telemetry pipeline while allowing authorized retrieval when needed.

OpenAI-specific tracing choices

Agents API traces

If you use the OpenAI Agents API, its tracing guide documents a dashboard view of agent, generation, and tool spans. Tool details can show call arguments, result when available, status, and error detail. Trace export returns OTLP JSON; it requires organization-level trace export to be enabled and an API key with trace-read or broader agent-read permission. See the Agents API tracing guide for the documented workflow.

Agents Python SDK

The OpenAI Agents SDK Python tracing documentation says sensitive data is included by default: generation and function spans can contain sensitive inputs and outputs, and trace_include_sensitive_data defaults to true. Setting it to false omits Responses model request and response content; the documented official-endpoint case still retains the response ID as correlation metadata. Check the SDK version and configuration in use rather than assuming a default applies unchanged.

The SDK also supports trace processors. Adding a processor leaves the default exporter registered; replacing processors does not send data to OpenAI unless an appropriate exporter is included. Processors are independent observers: an exception in one callback does not stop other registered processors. Therefore, a redaction processor that fails does not by itself prevent another processor—including the default exporter, if still installed—from receiving data. Validate processor and exporter configuration, and make the desired failure behavior explicit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose an instrumentation approach

Approach What it offers Key decision
OpenAI Agents API tracing Dashboard inspection of agent, generation, and tool spans; documented OTLP JSON trace export. Whether the documented platform view and export permissions fit your workflow.
OpenAI Agents Python SDK tracing SDK trace processors and a sensitive-data setting; processor configuration controls where traces are sent. Whether default payload capture is acceptable and whether the configured processors and exporters enforce your policy.
OpenTelemetry GenAI conventions Vendor-neutral semantic conventions for GenAI and agent spans. Framework compatibility, payload control, backend limits, external content storage, and your ability to operate the collector and export pipeline.

These are instrumentation choices, not interchangeable guarantees about what is collected or retained. Confirm actual framework behavior, exporter configuration, and backend policy before relying on a trace for debugging or oversight.

Logging for security is broader than tool spans

A tool-call trace helps explain an execution, but it is not automatically a complete audit log. If the security purpose requires an account of agent behavior, instrument relevant actions, permitted inputs and outputs, internal state changes, errors, timestamps and durations, and contextual identifiers. The Singapore government’s Securing Agentic AI addendum recommends monitoring tool activity and considering privacy requirements for logged inputs.

Set access and retention according to data sensitivity, operational needs, and applicable rules. The cited guidance does not establish a universal retention period or provide a one-size-fits-all compliance recipe.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.