Add opentelemetry-instrumentation-genai-smolagents instrumentation package - #340
Conversation
|
|
Pull request dashboard statusWaiting on the author · refreshed 2026-08-04 00:09 UTC Move out of draft to request review. Status above doesn't look right?
|
e527527 to
7277408
Compare
|
Split the PR, first part is the skeleton: #349 |
d5b57c7 to
e481cfb
Compare
e481cfb to
0f72e9a
Compare
…package Port openinference-instrumentation-smolagents into a new opentelemetry-instrumentation-genai-smolagents package that emits telemetry only through the public opentelemetry-util-genai API. Instruments MultiStepAgent.run (invoke_agent, sync and streaming), the model classes that define generate or generate_stream (chat), and the tool classes that define __call__ (execute_tool). A streamed chat span stays open until the caller drains the deltas. ToolCallingAgent.process_tool_calls is wrapped without a span of its own: it carries the provider's tool call id down to the execute_tool spans of the step. Also patches local_python_executor.timeout so tool spans started from agent-generated code keep the agent span as their parent instead of becoming root spans. Tests run against smolagents 1.24.0, the declared floor, and the latest release. Known gaps: - No span for an agent step. Neither the semantic conventions nor util-genai have a step or chain concept, so the OpenInference "Step N" CHAIN spans are dropped and tool and inference spans nest directly under invoke_agent. Tracked in open-telemetry/semantic-conventions-genai#81. - A streamed chat span reports no gen_ai.response.id and no gen_ai.response.model, because a smolagents stream delta carries neither. It reports a finish reason only when the model requested tool calls. - gen_ai.tool.call.id is omitted for a CodeAgent, whose model writes code instead of tool calls, and when one step calls the same tool twice. Tool.__call__ receives only the argument values, so the id is matched by tool name, and two calls to one tool have no unambiguous match. - A user-defined Model subclass that overrides generate shadows the patched base method and emits no chat span.
0f72e9a to
67581e2
Compare
Migration review: opentelemetry-instrumentation-genai-smolagentsMode: greenfield migration (the predecessor commit Compared against:
1. Instrumented API surface
2. Gaps and open issues
3. Significant behavioral changes
4. Test coverage
4a. Unit-test matrix per wrapped methodnone smolagents exposes no async API in 1.24.0 or 1.26.0 (no Cassettes: all 5 under 4b. Conformance scenarios
4c. Docstring / README coveragenone 5. Follow-up workNothing blocks this PR. Follow-ups, each its own PR: API surface
util-genai gaps
Behavioral parity
|
Description
Ports
openinference-instrumentation-smolagentsinto a newopentelemetry-instrumentation-genai-smolagentspackage. All telemetry is emitted through the publicopentelemetry-util-genaiAPI.What is instrumented:
MultiStepAgent.run, sync and streaming, asinvoke_agentgenerate, aschatTool.__call__, asexecute_toolIt also wraps smolagents'
local_python_executor.timeout, so tool spans started from agent-generated code keep the agent span as their parent instead of becoming root spans.Known gaps, also listed in the package
README.rst:opentelemetry-util-genaihave a step or chain concept, so the OpenInference "Step N" CHAIN spans are dropped andchatandexecute_toolspans nest directly underinvoke_agent. See Adding ReAct Iterations Spans in Reasoning-Acting Agents semantic-conventions-genai#81.Model.generate_streamis not instrumented, so an agent created withstream_outputs=Truereports nochatspan and no token usage.Modelsubclass that overridesgenerateshadows the patched base method and reports nochatspan. A subclass that inheritsgenerateis instrumented.PipelineTool, including the shippedSpeechToTextTool, overridesTool.__call__and reports noexecute_toolspan.gen_ai.tool.call.idis not recorded.Tool.__call__receives only the argument values, so the provider's tool call id never reaches the instrumentation.Part of #141
Type of change
How has this been tested?
Unit tests for the agent, model and tool patches, VCR-backed, and Weaver conformance scenarios for
invoke_agent,chatand multimodal input. Run against smolagents 1.24.0:Checklist
See CONTRIBUTING.md
for the style guide, changelog guidance, and more.