Skip to content

no agent name in stream

36ca817
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

no agent name in stream
36ca817
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Mar 31, 2026 in 4m 6s

2 issues

code-review: Found 2 issues (1 medium, 1 low)

Medium

GEN_AI_AGENT_NAME not set in new_stream function - `sentry_sdk/integrations/langchain.py:1029-1030`

The new_stream function retrieves run_name at line 1020 but never sets SPANDATA.GEN_AI_AGENT_NAME on the span, unlike new_invoke which correctly sets it (line 967-968). This is an oversight in the refactoring - the old code had span.set_data(SPANDATA.GEN_AI_AGENT_NAME, agent_name) which was removed but not replaced. This breaks parity between streaming and non-streaming agent invocations and conflicts with the PR's stated goal to set agent name as gen_ai.agent.name.

Low

Missing test coverage for agent name extraction from metadata - `sentry_sdk/integrations/langchain.py:429-433`

The PR adds logic to extract lc_agent_name from kwargs.get("metadata") in on_chat_model_start, but the test file shows no tests for this feature. The skill instructions state that every PR should have appropriate test coverage. Without tests, it's unclear if the agent name extraction works correctly when metadata is present, absent, or contains an invalid type.


Duration: 4m 1s · Tokens: 1.1M in / 12.4k out · Cost: $1.54 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.00)

Annotations

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

See this annotation in the file changed.

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

GEN_AI_AGENT_NAME not set in new_stream function

The `new_stream` function retrieves `run_name` at line 1020 but never sets `SPANDATA.GEN_AI_AGENT_NAME` on the span, unlike `new_invoke` which correctly sets it (line 967-968). This is an oversight in the refactoring - the old code had `span.set_data(SPANDATA.GEN_AI_AGENT_NAME, agent_name)` which was removed but not replaced. This breaks parity between streaming and non-streaming agent invocations and conflicts with the PR's stated goal to set agent name as `gen_ai.agent.name`.