◐ Shell
clean mode source ↗

fix(langchain): Set agent name as `gen_ai.agent.name` for chat and tool spans by alexander-alderman-webb · Pull Request #5877 · getsentry/sentry-python

@alexander-alderman-webb

Description

Set lc_agent_name as the gen_ai.agent.name attribute in on_chat_model_start() and in on_tool_start().

Remove manual accounting of the run_name attribute.

Issues

Reminders

@github-actions

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

Bug Fixes 🐛

  • (langchain) Set agent name as gen_ai.agent.name for chat and tool spans by alexander-alderman-webb in #5877

🤖 This preview updates automatically when you update the PR.

@alexander-alderman-webb alexander-alderman-webb changed the title fix(langchain): Set agent name as gen_ai.agent.name fix(langchain): Set agent name as gen_ai.agent.name

Mar 31, 2026

@github-actions

Codecov Results 📊

13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 6.82s

All tests are passing successfully.

❌ Patch coverage is 0.00%. Project has 14939 uncovered lines.

Files with missing lines (1)
File Patch % Lines
langchain.py 3.24% ⚠️ 568 Missing

Generated by Codecov Action

sentry-warden[bot]

sentry-warden[bot]

sentry-warden[bot]

sentry-warden[bot]

sentry-warden[bot]

cursor[bot]

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@alexander-alderman-webb alexander-alderman-webb changed the title fix(langchain): Set agent name as gen_ai.agent.name fix(langchain): Set agent name as gen_ai.agent.name for chat and tool spans

Apr 1, 2026

ericapisani

)


def _push_agent(agent_name: "Optional[str]") -> None:

Choose a reason for hiding this comment

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

Nice to be getting rid of this code 🔥

ericapisani

sentry[bot]