Skip to content

simplify

0d43616
Select commit
Loading
Failed to load commit list.
Open

fix(langchain): Set agent name as gen_ai.agent.name for chat and tool spans #5877

simplify
0d43616
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Mar 31, 2026 in 4m 21s

1 issue

code-review: Found 1 issue (1 medium)

Medium

Inconsistent GEN_AI_AGENT_NAME handling between invoke and stream - `sentry_sdk/integrations/langchain.py:964-965`

The new_invoke function still sets GEN_AI_AGENT_NAME on the span using run_name (line 964-965), while new_stream had this code removed entirely. This creates inconsistent telemetry behavior where invoke_agent spans will have different attributes depending on whether invoke() or stream() is called. According to the PR description, lc_agent_name should be used as the agent name source through callback handlers, suggesting the setting in new_invoke should also be removed.


Duration: 4m 21s · Tokens: 1.0M in / 11.7k out · Cost: $1.73

Annotations

Check warning on line 965 in sentry_sdk/integrations/langchain.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: code-review

Inconsistent GEN_AI_AGENT_NAME handling between invoke and stream

The `new_invoke` function still sets `GEN_AI_AGENT_NAME` on the span using `run_name` (line 964-965), while `new_stream` had this code removed entirely. This creates inconsistent telemetry behavior where `invoke_agent` spans will have different attributes depending on whether `invoke()` or `stream()` is called. According to the PR description, `lc_agent_name` should be used as the agent name source through callback handlers, suggesting the setting in `new_invoke` should also be removed.