openai / openai/openai-agents-python

Traces appear but spans show "No spans found" despite successful export

Open
#2,477 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature:tracing server issue
Dominant language
Python
Stars
29.6k
Forks
4.8k
Avg merge
1d 20h
Merged PRs (30d)
123

Description

Image
Description

When using the SDK tracing API, traces show up in the OpenAI Platform Traces UI but opening a trace shows "No spans found". Verbose logging shows 4 items exported (1 trace + 3 spans), and the ingest API returns 204, so export appears to succeed.

Expected behavior
  • Trace and spans appear in the UI
  • Spans are nested under the trace (AgentSpan, CustomSpan, ResponseSpan, etc.)
Actual behavior
  • Trace appears with correct metadata
  • UI shows "No spans found"
  • Logs show Exported 4 items and the request returns 204
Verbose debug output

With enable_verbose_stdout_logging(), we see spans created and exported:

Setting current trace: trace_xxx
Creating span <CustomSpanData> with id None
Creating span <AgentSpanData> with id None
Running agent Greeter (turn 1)
Creating span <ResponseSpanData> with id None
...
Resetting current trace
Shutting down trace provider
Shutting down trace processor
Exported 4 items

So 4 items (1 trace + 3 spans) are sent and the export succeeds, but the UI still shows no spans.

Minimal reproduction
import asyncio
import os

from dotenv import load_dotenv
load_dotenv(override=True)

from agents import Agent, Runner, custom_span, gen_trace_id, trace
from agents import set_tracing_export_api_key, set_trace_processors
from agents.tracing import default_exporter
from agents.tracing.processors import BatchTraceProcessor

if os.environ.get("OPENAI_API_KEY"):
    set_tracing_export_api_key(os.environ["OPENAI_API_KEY"])

# Long schedule_delay so trace + spans export together on shutdown
# (avoids 5s timer exporting trace before spans finish)
processor = BatchTraceProcessor(default_exporter(), schedule_delay=3600.0)
set_trace_processors([processor])

async def main():
    trace_id = gen_trace_id()
    workflow_trace = trace("trace_test", trace_id=trace_id)
    print(f"View trace: https://platform.openai.com/traces/trace?trace_id={trace_id}")
    workflow_trace.start(mark_as_current=True)

    agent = Agent(
        name="Greeter",
        instructions="You are helpful. Reply briefly.",
        model="gpt-4o-mini",
    )

    with custom_span(name="agent_run", data={"query": "hello"}):
        result = await Runner.run(agent, "Say hello in one word.")

    print(f"Result: {result.final_output}")
    workflow_trace.finish(reset_current=True)
    processor.force_flush()
    print(f"Done. Check trace: https://platform.openai.com/traces/trace?trace_id={trace_id}")

if __name__ == "__main__":
    asyncio.run(main())
What we tried
  1. force_flush() before exit – still no spans in UI
  2. set_trace_processors with schedule_delay=3600 – to keep trace and spans in the same export batch (default 5s timer can export trace before spans finish) – still no spans
  3. set_tracing_export_api_key() – API key is set and ingest returns 204
  4. New vs old API key – same behavior
Environment
  • openai-agents-0.8.4
  • Python 3.12
  • macOS
Questions
  1. Is there a known gap or bug in the Platform Traces UI for ingested spans?
  2. Does the ingest API accept spans but not surface them in the UI?
  3. Is there a required payload or ordering for spans in the ingest request?

Related: #31 (trace visibility issues), #1845 (RealtimeAgent traces without spans)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal reproduction and inspect default_exporter and BatchTraceProcessor, especially the payload and ordering sent after processor.force_flush(). Compare the exported trace and span identifiers with what the Traces UI displays, and verify the result against related issues #31 and #1845. Done means successfully exported spans appear nested under the trace in the UI.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, observability-sre
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.