Skip to content

Commit 98e51d0

Browse files
cursoragentclaude
andcommitted
fix(langchain): Normalize gen_ai.system for OpenAI and Anthropic consistency
Restore normalization of LangChain _type values to match the gen_ai.system values used by dedicated OpenAI and Anthropic integrations. This fixes a regression where 'openai-chat' and 'anthropic-chat' were returned as-is instead of being normalized to 'openai' and 'anthropic'. The fix ensures consistent gen_ai.system values across all integration paths, preventing breakage of existing Sentry dashboards, alerts, and queries that filter on these normalized provider names. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 1bc78cc commit 98e51d0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

‎sentry_sdk/integrations/langchain.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ def _get_ai_system(all_params: "Dict[str, Any]") -> "Optional[str]":
114114
if not ai_type or not isinstance(ai_type, str):
115115
return None
116116

117+
if "anthropic" in ai_type:
118+
return "anthropic"
119+
elif "openai" in ai_type:
120+
return "openai"
121+
117122
return ai_type
118123

119124

‎tests/integrations/langchain/test_langchain.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,13 +2005,13 @@ def test_transform_google_file_data(self):
20052005
[
20062006
# Real LangChain _type values (from _llm_type properties)
20072007
# OpenAI
2008-
("openai-chat", "openai-chat"),
2008+
("openai-chat", "openai"),
20092009
("openai", "openai"),
20102010
# Azure OpenAI
2011-
("azure-openai-chat", "azure-openai-chat"),
2011+
("azure-openai-chat", "openai"),
20122012
("azure", "azure"),
20132013
# Anthropic
2014-
("anthropic-chat", "anthropic-chat"),
2014+
("anthropic-chat", "anthropic"),
20152015
# Google
20162016
("vertexai", "vertexai"),
20172017
("chat-google-generative-ai", "chat-google-generative-ai"),

0 commit comments

Comments
 (0)