Skip to content

fix span description

56ec48f
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

fix span description
56ec48f
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Mar 31, 2026 in 4m 5s

1 issue

code-review: Found 1 issue (1 medium)

Medium

new_stream does not set GEN_AI_AGENT_NAME when agent_name is None but run_name exists - `sentry_sdk/integrations/langchain.py:1032-1033`

In new_stream, when agent_name from metadata is None but run_name exists, the span name correctly falls back to run_name (line 1022-1023), but GEN_AI_AGENT_NAME data attribute is never set (line 1032-1033 only checks agent_name is not None). This differs from new_invoke which sets GEN_AI_AGENT_NAME to run_name when truthy. Users calling stream() without explicit metadata but with a configured run_name will have inconsistent telemetry - the span name shows the agent name but the data attribute doesn't.


Duration: 4m 6s · Tokens: 1.0M in / 12.9k out · Cost: $1.62 (+extraction: $0.00)

Annotations

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

See this annotation in the file changed.

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

new_stream does not set GEN_AI_AGENT_NAME when agent_name is None but run_name exists

In `new_stream`, when `agent_name` from metadata is None but `run_name` exists, the span name correctly falls back to `run_name` (line 1022-1023), but `GEN_AI_AGENT_NAME` data attribute is never set (line 1032-1033 only checks `agent_name is not None`). This differs from `new_invoke` which sets `GEN_AI_AGENT_NAME` to `run_name` when truthy. Users calling `stream()` without explicit metadata but with a configured `run_name` will have inconsistent telemetry - the span name shows the agent name but the data attribute doesn't.