Problem
I am using Phoenix and connect Smolagents to it via OTLP.
With latest dependencies, I am seeing the following spans:
FinalAnswerTool (type tool, no parent)
MCPAdaptTool (type tool, no parent)
- CodeAgent.run (type
agent)
- Step 1 (type
chain)
OpenAIModel.generate (type llm)
- Step 2 (type
chain)
OpenAIModel.generate (type llm)
i.e. the tools are missing the parent and are therefore considered root spans
Previously recorded spans have the following structure:
- CodeAgent.run (type
agent)
MCPAdaptTool (type tool)
FinalAnswerTool (type tool)
i.e. previously tool spans have the agent span as the parent
Steps to reproduce
Please provide a minimal, self-contained, and reproducible example of the bug.
import logging
import os
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from openinference.instrumentation.smolagents import SmolagentsInstrumentor
import smolagents
LOGGER = logging.getLogger(__name__)
def configure_otlp(otlp_endpoint: str):
LOGGER.info('Configuring OTLP: %r', otlp_endpoint)
trace_provider = TracerProvider()
trace_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(otlp_endpoint)))
SmolagentsInstrumentor().instrument(tracer_provider=trace_provider)
def get_model() -> smolagents.Model:
return smolagents.OpenAIModel(
model_id='gpt-5-mini',
api_key=os.environ['OPENAI_API_KEY']
)
@smolagents.tool
def today_tool() -> str:
"""
Provides the current date.
"""
return "Today is 2026-01-29."
def create_agent() -> smolagents.CodeAgent:
tools = [
today_tool
]
return smolagents.CodeAgent(
tools=tools,
max_steps=3,
model=get_model()
)
def main():
configure_otlp('http://0.0.0.0:6006/v1/traces')
agent = create_agent()
agent.run("What is today's date?")
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
main()
Actual behavior and error logs
The following spans are created:
FinalAnswerTool (type tool, no parent)
SimpleTool (type tool, no parent)
- CodeAgent.run (type
agent)
- Step 1 (type
chain)
OpenAIModel.generate (type llm)
i.e. the tools are missing the parent and are therefore considered root spans
Expected behavior
A clear and concise description of what you expected to happen.
Expected spans:
- CodeAgent.run (type
agent)
- Step 1 (type
chain)
OpenAIModel.generate (type llm)
SimpleTool (type tool)
FinalAnswerTool (type tool)
i.e. the tool spans should have a parent of the corresponding step
Environment:
Please complete the following information:
- OS: [e.g., Linux, macOS, Windows]
- Python version: [e.g., 3.10]
- Package version: (output of
pip show smolagents)
OS: Linux
Python version: 3.12.3
Package version: 1.24.0
Relevant dependencies
$ pip list | grep -P 'opentelemetry|openinference|smol|phoenix'
arize-phoenix 12.33.0
arize-phoenix-client 1.28.0
arize-phoenix-evals 2.8.0
arize-phoenix-otel 0.14.0
openinference-instrumentation 0.1.43
openinference-instrumentation-smolagents 0.1.21
openinference-semantic-conventions 0.1.25
opentelemetry-api 1.39.1
opentelemetry-exporter-otlp 1.39.1
opentelemetry-exporter-otlp-proto-common 1.39.1
opentelemetry-exporter-otlp-proto-grpc 1.39.1
opentelemetry-exporter-otlp-proto-http 1.39.1
opentelemetry-instrumentation 0.60b1
opentelemetry-proto 1.39.1
opentelemetry-sdk 1.39.1
opentelemetry-semantic-conventions 0.60b1
smolagents 1.24.0
Additional context (optional)
Add any other context, screenshots, or links about the bug here.
screenshot of previous agent span
screenshot of new agent span
screenshot of new root spans
This is working correctly when using the ToolCallingAgent (instead of CodeAgent).
screenshot of ToolCallingAgent.run span with correct hierarchy
---
Checklist
(I didn't tick the last box because I don't really understand how the telemetry works)
Problem
I am using Phoenix and connect Smolagents to it via OTLP.
With latest dependencies, I am seeing the following spans:
FinalAnswerTool(typetool, no parent)MCPAdaptTool(typetool, no parent)agent)chain)OpenAIModel.generate(typellm)chain)OpenAIModel.generate(typellm)i.e. the tools are missing the parent and are therefore considered root spans
Previously recorded spans have the following structure:
agent)MCPAdaptTool(typetool)FinalAnswerTool(typetool)i.e. previously tool spans have the agent span as the parent
Steps to reproduce
Please provide a minimal, self-contained, and reproducible example of the bug.
Actual behavior and error logs
The following spans are created:
FinalAnswerTool(typetool, no parent)SimpleTool(typetool, no parent)agent)chain)OpenAIModel.generate(typellm)i.e. the tools are missing the parent and are therefore considered root spans
Expected behavior
A clear and concise description of what you expected to happen.
Expected spans:
agent)chain)OpenAIModel.generate(typellm)SimpleTool(typetool)FinalAnswerTool(typetool)i.e. the tool spans should have a parent of the corresponding step
Environment:
Please complete the following information:
pip show smolagents)Relevant dependencies
Additional context (optional)
Add any other context, screenshots, or links about the bug here.
screenshot of previous agent span
screenshot of new agent span
screenshot of new root spans
This is working correctly when using the
ToolCallingAgent(instead ofCodeAgent).screenshot of ToolCallingAgent.run span with correct hierarchy
Checklist
(I didn't tick the last box because I don't really understand how the telemetry works)