Skip to content

[OpenAI Agents] MCP List Tools spans show only as "unknown" with no data #4197

@adammw

Description

@adammw

Describe your environment

OS: macOS 26.2
Python version: Python 3.13.7
Package version: opentelemetry-instrumentation-openai-agents-v2 0.1.0

What happened?

Testing with OpenAI Agents SDK and an agent that has access to an MCP server, an "unknown" span is created when the agent fetches the list of MCP tools.

Steps to Reproduce

Run the following code, notice the OTEL console span output after the "DEBUG:openai.agents:Creating span <agents.tracing.span_data.MCPListToolsSpanData..." line

from agents import (
    Agent,
    Runner,
)
from agents.tracing import set_trace_processors
from agents.mcp.server import MCPServerStdio
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, ConsoleSpanExporter
from opentelemetry.instrumentation.openai_agents import OpenAIAgentsInstrumentor
import asyncio

import logging
logging.basicConfig(level=logging.DEBUG)

# Clear default OpenAI tracing
set_trace_processors([])

# Configure OpenTelemetry tracing
provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))
trace.set_tracer_provider(provider)

# Instrument OpenAI Agents with OpenTelemetry
OpenAIAgentsInstrumentor().instrument(tracer_provider=provider)

async def main():
    print('calling agent')
    async with MCPServerStdio(
        name="Time",
        params={
            "command": "uvx",
            "args": [
                "mcp-server-time"
            ]
        }
    ) as mcp_server:
        agent = Agent(
            name="MCP Agent",
            instructions="You are an agent with access to a tool that can execute commands. Use this tool to execute the command and return the output. The tool will return the output of the command execution.",
            model="gpt-4o-mini",
            mcp_servers=[mcp_server]
        )
        llm_response = await Runner.run(
            agent,
            "What is the current time?"
        )

        result = llm_response.final_output
        print(result)

if __name__ == "__main__":
    asyncio.run(main())

Expected Result

A "list tools" span is created with server and result attributes mapped to gen_ai attributes.

Actual Result

An "unknown" span is created with no discerning attributes

{
    "name": "unknown",
    "context": {
        "trace_id": "0x96f1903c189ce6e246b32a17d27d821a",
        "span_id": "0x56ae050862eb125a",
        "trace_state": "[]"
    },
    "kind": "SpanKind.INTERNAL",
    "parent_id": "0x60f3483ad2f66fbb",
    "start_time": "2026-02-13T04:25:24.052783Z",
    "end_time": "2026-02-13T04:25:24.055009Z",
    "status": {
        "status_code": "OK"
    },
    "attributes": {
        "gen_ai.operation.name": "unknown",
        "gen_ai.provider.name": "openai",
        "gen_ai.system": "openai",
        "gen_ai.agent.name": "OpenAI Agent",
        "gen_ai.agent.id": "agent",
        "gen_ai.agent.description": "OpenAI Agents instrumentation",
        "server.address": "api.openai.com",
        "server.port": 443
    },
    "events": [],
    "links": [],
    "resource": {
        "attributes": {
            "telemetry.sdk.language": "python",
            "telemetry.sdk.name": "opentelemetry",
            "telemetry.sdk.version": "1.39.1",
            "service.name": "unknown_service"
        },
        "schema_url": ""
    }
}

Additional context

No response

Would you like to implement a fix?

None

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions