Skip to content

OpenAI Agents root span uses SERVER instead of INTERNAL #154

@mznet

Description

@mznet

Describe your environment

OS: Tahoe 26.3
Python version: 3.13.9
Package version: 1.0b0.dev
GenAI library (e.g. anthropic, openai) and version: openai-agents 0.17.6

What happened?

OpenAI Agents Instrumentation records SpanKind as SERVER in root span. This logic is called in on_trace_start method in GenAISemanticProcessor and its comment says "# Root span is typically server", but I couldn't find any grounds in semantic-conventions-gen-ai and it seems to be incorrect given the definition of SERVER.

Steps to Reproduce

from agents.tracing import trace, set_trace_processors
from opentelemetry.instrumentation.openai_agents import OpenAIAgentsInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, ConsoleSpanExporter

set_trace_processors([])
provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))

OpenAIAgentsInstrumentor().instrument(tracer_provider=provider)

with trace("workflow"):
    pass

Console Exporter result is as shown below:

{
    "name": "workflow",
    "context": {
        "trace_id": "0xc2eeeb857a4fd2ef43732413e6b024c9",
        "span_id": "0xccf03ff8895dd4fb",
        "trace_state": "[]"
    },
    "kind": "SpanKind.SERVER",
    "parent_id": null,
    "start_time": "2026-06-19T07:15:07.896064Z",
    "end_time": "2026-06-19T07:15:07.896073Z",
    "status": {
        "status_code": "OK"
    },
    "attributes": {
        "gen_ai.provider.name": "openai",
        "gen_ai.system": "openai",
        "gen_ai.operation.name": "invoke_agent",
        "server.address": "api.openai.com",
        "server.port": 443
    },
    "events": [],
    "links": [],
    "resource": {
        "attributes": {
            "telemetry.sdk.language": "python",
            "telemetry.sdk.name": "opentelemetry",
            "telemetry.sdk.version": "1.42.1",
            "service.name": "unknown_service"
        },
        "schema_url": ""
    }
}

Expected Result

SpanKind should be INTERNAL.

Actual Result

The instrumentation records SpanKind as SERVER.

Additional context

The OpenAI Agents Instrumentation in OpenLLMetry records SpanKind as INTERNAL when it creates a root span.
https://github.com/traceloop/openllmetry/blob/main/packages/opentelemetry-instrumentation-openai-
agents/opentelemetry/instrumentation/openai_agents/_hooks.py#L662

Would you like to implement a fix?

Yes

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    New issues

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions