maple-agent-tracing-smolagents
Installation
SKILL.md
Maple agent tracing: smolagents
Goal: every conversation the app runs through a smolagents agent shows up in Maple Agent Sessions as ONE session, with the transcript, each model call (model, tokens), each tool call (name, arguments, result, failure) and one lane per managed agent.
All spans come from openinference-instrumentation-smolagents.
Step 0: Detect versions and existing OpenTelemetry
- Read
pyproject.toml/requirements*.txt/uv.lock/poetry.lock. Needsmolagents>=1.26and Python >=3.10. If older, upgrade smolagents first. - Find which model class the app uses (
OpenAIServerModel/OpenAIModel,LiteLLMModel,InferenceClientModel,AzureOpenAIModel,AmazonBedrockModel,TransformersModel...). Note any customModelsubclass that overridesgenerate: it will produce NO model spans. - Find every
agent.run(...)call site and how conversations are identified (chat id, thread id, session row). - Search for an existing
TracerProvider,trace.set_tracer_provider,opentelemetry-instrument,logfire.configure,phoenix.otel.register,langfuse, orSmolagentsInstrumentoralready present. If a provider exists, REUSE it: add Maple's exporter and the processor below to it, pass it toinstrument(). Never create a second provider. IfSmolagentsInstrumentor().instrument()already runs, change that call instead of adding another (a second call is a silent no-op). - Search for
openinference-instrumentation-openai,openinference-instrumentation-litellm,OpenAIInstrumentor,LiteLLMInstrumentor. If present only to trace smolagents' model calls, remove them (they double every model span).