Back to catalog / Agent observability
Trace model, tool, and handoff spans in an agent run
Correlate model calls, tool execution, guardrails, and handoffs in one workflow timeline for diagnosis.
Goal
Identify where an agent task slowed, failed, or diverged from expectations.
Steps
- Set tracing scope, retention, and sensitive fields that must never be recorded. [openai-tracing]
- Wrap one or more
Runner.run(...)calls inwith trace("agent-workflow"):to group them in one trace. [openai-tracing] - Use SDK tracing or a custom processor to capture agent, model, tool, and handoff spans. [openai-tracing]
- Call
flush_traces()after the trace closes when immediate export is needed; configure a processor or disable tracing per policy. [openai-tracing] - Restrict export under organizational data policy; disable external tracing when prohibited. [openai-tracing]
How to verify
A single workflow trace should locate tool and model stages; verify no keys or unnecessary personal data are recorded.
Troubleshooting
If spans are missing, check tracing configuration and processor flushing; do not log credentials to diagnose export.
Permissions
Prerequisites
- Python 3.10+, openai-agents compatible with the pinned revision, and authorized model-provider credentials (except local mock tests)
Permissions
- Use a local or isolated test environment; use least privilege and approval for external data or side effects
Limitations
Tracing is enabled by default and unavailable under ZDR. Keep tokens, personal data, and sensitive tool payloads out of trace metadata.
Pinned upstream source
- Repository
- openai/openai-agents-python
- File path
- docs/tracing.md
- Pinned commit
f53c62451c7f34c15f0c87fa745e05404025420f- Source checked
- 2026-10-14 · Reviewed against the pinned upstream source
Repository metrics
These values describe the upstream repository, not popularity or likes for an individual skill or playbook.
- Stars
- Not collected
- Forks
- Not collected
- Observed at
- Not collected
No metrics snapshot is available yet.
License: MIT
Main topic
Take a coding Agent change from context to verification