Skip to content

fix: Stringify gen_ai.tool.output attribute#6086

Closed
alexander-alderman-webb wants to merge 2 commits intomasterfrom
webb/repr-tool-output
Closed

fix: Stringify gen_ai.tool.output attribute#6086
alexander-alderman-webb wants to merge 2 commits intomasterfrom
webb/repr-tool-output

Conversation

@alexander-alderman-webb
Copy link
Copy Markdown
Contributor

Description

Issues

Reminders

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (ci) Cancel in-progress PR workflows on new commit push by joshuarli in #5994
  • Add db.driver.name spans to database integrations by ericapisani in #6082

Bug Fixes 🐛

  • (google_genai) Redact binary data in inline_data and fix multi-part message extraction by ericapisani in #5977
  • (grpc) Add isolation_scope to async server interceptor by robinvd in #5940
  • (profiler) Stop nulling buffer on teardown by ericapisani in #6075
  • Stringify gen_ai.tool.output attribute by alexander-alderman-webb in #6086

Internal Changes 🔧

  • (celery) Remove unused NoOpMgr from utils by sentrivana in #6078
  • (pydantic-ai) Remove dead Model.request patch by alexander-alderman-webb in #5956
  • (tests) Replace deprecated enable_tracingwith traces_sample_rate by sentrivana in #6077
  • Set explicit base-branch for codecov action by ericapisani in #5992

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

Codecov Results 📊

27 passed | Total: 27 | Pass Rate: 100% | Execution Time: 4.51s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests 📈 +2
Failed Tests
Skipped Tests 📉 -2

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 40.00%. Project has 15422 uncovered lines.
❌ Project coverage is 27.82%. Comparing base (base) to head (head).

Files with missing lines (3)
File Patch % Lines
langchain.py 3.25% ⚠️ 595 Missing
utils.py 14.71% ⚠️ 87 Missing
execute_tool.py 0.00% ⚠️ 25 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    28.41%    27.82%    -0.59%
==========================================
  Files          190       190         —
  Lines        21354     21366       +12
  Branches      7068      7068         —
==========================================
+ Hits          6067      5944      -123
- Misses       15287     15422      +135
- Partials       558       557        -1

Generated by Codecov Action

Comment on lines +691 to +693
set_data_normalized(
span, SPANDATA.GEN_AI_TOOL_OUTPUT, safe_repr(output)
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safe_repr with set_data_normalized double-quotes string tool outputs

Using safe_repr(output) when output is a string adds Python repr quotes (e.g., "hello" becomes "'hello'"). The existing test at line 736 of test_langchain.py expects to call int() on the tool output - this will fail if the output "5" becomes "'5'". Other integrations use safe_repr directly with span.set_data(), not with set_data_normalized() which already handles type conversion.

Verification

Traced through safe_repr (sentry_sdk/utils.py line 562-566) which calls repr() on values. For strings, repr() adds quotes. Verified set_data_normalized (sentry_sdk/ai/utils.py lines 492-499) passes strings through unchanged. Confirmed existing test at tests/integrations/langchain/test_langchain.py:736 calls int() on tool output, which would fail with quoted strings.

Identified by Warden code-review · RLV-WJ8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant