fix(ai): remove setting of GEN_AI_AGENT_NAME from langchain#5728
fix(ai): remove setting of GEN_AI_AGENT_NAME from langchain#5728harryautomazione wants to merge 2 commits intogetsentry:masterfrom
Conversation
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛Anthropic
Other
Documentation 📚
Internal Changes 🔧
Other
🤖 This preview updates automatically when you update the PR. |
9163994 to
bd0b816
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| name=f"invoke_agent {agent_name}" if agent_name else "invoke_agent", | ||
| origin=LangchainIntegration.origin, | ||
| ) as span: | ||
| _push_agent(agent_name) |
There was a problem hiding this comment.
Empty finally block with stale misleading comment
Low Severity
The try/finally block in _wrap_agent_executor_invoke is now empty — the finally clause only contains a stale comment ("Ensure agent is popped even if an exception occurs") with no actual code. The entire try/finally construct is now dead scaffolding that adds indentation and a misleading comment suggesting cleanup is happening when it isn't. The try/finally wrapper can be removed entirely.
|
|
||
|
|
||
| # Contextvar to track agent names in a stack for re-entrant agent support | ||
| _agent_stack: "contextvars.ContextVar[Optional[List[Optional[str]]]]" = ( |
There was a problem hiding this comment.
Stale contextvar comment above unrelated function definition
Low Severity
The comment # Contextvar to track agent names in a stack for re-entrant agent support at line 156 is now orphaned — it previously described _agent_stack and the related _push_agent/_pop_agent/_get_current_agent functions that were all removed. It now misleadingly sits directly above the unrelated _get_system_instructions function.
|
|
||
|
|
||
| # Contextvar to track agent names in a stack for re-entrant agent support | ||
| _agent_stack: "contextvars.ContextVar[Optional[List[Optional[str]]]]" = ( |
…mand, parameter name, and attribute - Change install command to include [pydantic_ai] extra - Change result_type to output_type in example - Change result.data to result.output in example This ensures the docstring matches the current Pydantic AI API and correct installation instructions.


Description
This PR removes the setting of
SPANDATA.GEN_AI_AGENT_NAMEfrom several places in thelangchainintegration, as pulling it from request parameters (likerun_name) was identified as semantically incorrect.The setting in
on_llm_startwas already removed in PR #5705. This completes the removal for other areas to fully resolve the issue.Changes
SPANDATA.GEN_AI_AGENT_NAMEinon_chat_model_start.on_tool_start._wrap_agent_executor_invoke._wrap_agent_executor_stream.Resolves: #5719