fix: route smolagents OpenInference spans to OpenInferenceSessionMapper - #308
Conversation
|
Assessment: Comment / minor changes requested Clean, well-scoped bugfix: routing smolagents' OpenInference scope through the existing mapper is the right call, and the Review Categories
Nice, targeted fix — addressing the non-dict output edge case would make it fully robust for real smolagents traces. |
71df22c to
e16bf0d
Compare
|
🔴 Follow-up on the "Important / Correctness" item from my review (re-posting as a general comment — the original inline note targeted Issue: This PR routes smolagents spans into # openinference_session_mapper.py ~L296
if isinstance(output_value, str):
parsed = json.loads(output_value) # "42" -> 42, "[1,2,3]" -> list, '"x"' -> str
tool_output_content = parsed.get("content", str(parsed)) # AttributeError on non-dict
...
except json.JSONDecodeError: # does NOT catch AttributeError
tool_output_content = str(output_value)The Verified against the current branch ( Suggestion: Only treat if isinstance(output_value, str):
try:
parsed = json.loads(output_value)
except json.JSONDecodeError:
parsed = None
if isinstance(parsed, dict):
tool_output_content = parsed.get("content", str(parsed))
tool_call_id = parsed.get("tool_call_id")
tool_status = parsed.get("status", "success")
else:
tool_output_content = output_value
elif isinstance(output_value, dict):
tool_output_content = output_value.get("content", str(output_value))And add a regression test with a numeric/list/JSON-string |
e16bf0d to
dd911a8
Compare
|
✅ Re-reviewed at The Thanks also for adding Minor / optional (non-blocking): the outer fallback was widened to Assessment: Approve — the substantive issue from my earlier review is fixed and well-tested. The |
|
🔁 Re-reviewed at Thread-by-thread verification
Two minor residual notes on tool-argument normalization (
Both are edge cases — the common smolagents kwargs-only path normalizes cleanly to Assessment: Approve (pending @jjbuck resolving their own threads). Nice turnaround — the normalization layer plus a real captured fixture is a solid, durable approach. |
6f3897f to
143b63e
Compare
|
🔁 Re-reviewed at Thread-by-thread verification
One minor, non-blocking note: positional→named mapping relies on Assessment: Approve. Both residual threads from my earlier pass are now fully addressed with exact assertions against the real captured fixture — clean, durable resolution. |
9a29d5f to
098d208
Compare
|
🔁 Re-checked at The suite count moved 79 → 70 passed, which I verified is consolidation, not a coverage regression: the previously standalone/inline tests were merged into
Assessment: Approve (unchanged). Cleaner test organization with equivalent coverage — no further concerns from my side. |
098d208 to
95fd070
Compare
|
🔁 Re-checked at Assessment: Approve (unchanged). The only remaining item is my earlier minor, non-blocking suggestion to add a one-line comment noting the positional→named mapping relies on |
Description
Problem
SmolagentsInstrumentor sets its OTel scope to "openinference.instrumentation.smolagents", but OpenInferenceSessionMapper only accepted "openinference.instrumentation.langchain". Smolagents spans were silently filtered out, producing empty Sessions with no tool data.
Fix
Add SCOPES_OPENINFERENCE_FAMILY — a set containing both the langchain and smolagents scope variants. detect_otel_mapper() and OpenInferenceSessionMapper's span filter now check membership in this set. The mapper's existing attribute parsing already handles smolagents' bare-string output.value format correctly.
Related Issues
Documentation PR
Type of Change
Bug fix
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.