Skip to content

fix(ai): remove setting of GEN_AI_AGENT_NAME from langchain#5728

Open
harryautomazione wants to merge 3 commits intogetsentry:masterfrom
harryautomazione:fix/issue-5719
Open

fix(ai): remove setting of GEN_AI_AGENT_NAME from langchain#5728
harryautomazione wants to merge 3 commits intogetsentry:masterfrom
harryautomazione:fix/issue-5719

Conversation

@harryautomazione
Copy link

Description

This PR removes the setting of SPANDATA.GEN_AI_AGENT_NAME from several places in the langchain integration, as pulling it from request parameters (like run_name) was identified as semantically incorrect.

The setting in on_llm_start was already removed in PR #5705. This completes the removal for other areas to fully resolve the issue.

Changes

  • Removed assignment of SPANDATA.GEN_AI_AGENT_NAME in on_chat_model_start.
  • Removed assignment in on_tool_start.
  • Removed assignment in _wrap_agent_executor_invoke.
  • Removed assignment in _wrap_agent_executor_stream.

Resolves: #5719

@harryautomazione harryautomazione requested a review from a team as a code owner March 20, 2026 19:18
@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 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 ✨

  • (asgi) Add option to disable suppressing chained exceptions by alexander-alderman-webb in #5714
  • (logging) Separate ignore lists for events/breadcrumbs and sentry logs by sl0thentr0py in #5698

Bug Fixes 🐛

Anthropic

  • Set exception info on streaming span when applicable by alexander-alderman-webb in #5683
  • Patch AsyncStream.close() and AsyncMessageStream.close() to finish spans by alexander-alderman-webb in #5675
  • Patch Stream.close() and MessageStream.close() to finish spans by alexander-alderman-webb in #5674

Other

  • (ai) Remove setting of GEN_AI_AGENT_NAME from langchain by harryautomazione in #5728

Documentation 📚

  • Add note on AI PRs to CONTRIBUTING.md by sentrivana in #5696

Internal Changes 🔧

  • Add -latest alias for each integration test suite by sentrivana in #5706
  • Use date-based branch names for toxgen PRs by sentrivana in #5704
  • 🤖 Update test matrix with new releases (03/19) by github-actions in #5703
  • Add client report tests for span streaming by sentrivana in #5677

Other

  • Update CHANGELOG.md by sentrivana in #5685

🤖 This preview updates automatically when you update the PR.

…gation

- Add CURRENT_LANGCHAIN_AGENT_NAME contextvar to track agent name across spans
- Set agent name in agent executor wrappers (invoke/stream)
- Propagate agent name to all child spans via _create_span
- Add test to verify agent name is set on all spans
- Correctly place the new test after test_langchain_agent
- Remove misplaced assertions that broke the original test
Copy link

@cursor cursor bot left a comment

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.

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