From b3e996479037a19c293385ac0a3376e1ccbe66ef Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 23 Sep 2026 15:35:38 +0200 Subject: [PATCH] chore(langgraph): Remove include_prompts parameter --- sentry_sdk/integrations/langgraph.py | 7 +-- .../integrations/langgraph/test_langgraph.py | 49 +++++-------------- 2 files changed, 14 insertions(+), 42 deletions(-) diff --git a/sentry_sdk/integrations/langgraph.py b/sentry_sdk/integrations/langgraph.py index 34bf8f7df3..07708dd007 100644 --- a/sentry_sdk/integrations/langgraph.py +++ b/sentry_sdk/integrations/langgraph.py @@ -32,9 +32,6 @@ class LanggraphIntegration(Integration): identifier = "langgraph" origin = f"auto.ai.{identifier}" - def __init__(self: "LanggraphIntegration", include_prompts: bool = True) -> None: - self.include_prompts = include_prompts - @staticmethod def setup_once() -> None: version = package_version("langgraph") @@ -60,7 +57,7 @@ def _should_record_inputs(integration: "LanggraphIntegration") -> bool: return bool(client.options["data_collection"]["gen_ai"]["inputs"]) # To remove once data collection has been fully rolled out - return should_send_default_pii() and integration.include_prompts + return should_send_default_pii() def _should_record_outputs(integration: "LanggraphIntegration") -> bool: @@ -69,7 +66,7 @@ def _should_record_outputs(integration: "LanggraphIntegration") -> bool: return bool(client.options["data_collection"]["gen_ai"]["outputs"]) # To remove once data collection has been fully rolled out - return should_send_default_pii() and integration.include_prompts + return should_send_default_pii() def _get_graph_name(graph_obj: "Any") -> "Optional[str]": diff --git a/tests/integrations/langgraph/test_langgraph.py b/tests/integrations/langgraph/test_langgraph.py index c5243357a4..a65b9f39aa 100644 --- a/tests/integrations/langgraph/test_langgraph.py +++ b/tests/integrations/langgraph/test_langgraph.py @@ -137,37 +137,18 @@ def _generate(self, messages, stop=None, run_manager=None, **kwargs) -> ChatResu raise GraphBubbleUp("interrupt") -def test_langgraph_integration_init(): - """Test LanggraphIntegration initialization with different parameters.""" - integration = LanggraphIntegration() - assert integration.include_prompts is True - assert integration.identifier == "langgraph" - assert integration.origin == "auto.ai.langgraph" - - integration = LanggraphIntegration(include_prompts=False) - assert integration.include_prompts is False - assert integration.identifier == "langgraph" - assert integration.origin == "auto.ai.langgraph" - - @pytest.mark.parametrize( - "send_default_pii, include_prompts", - [ - (True, True), - (True, False), - (False, True), - (False, False), - ], + "send_default_pii", + [True, False], ) def test_pregel_invoke( sentry_init, capture_items, send_default_pii, - include_prompts, ): """Test Pregel.invoke() wrapper creates proper invoke_agent span.""" sentry_init( - integrations=[LanggraphIntegration(include_prompts=include_prompts)], + integrations=[LanggraphIntegration()], traces_sample_rate=1.0, send_default_pii=send_default_pii, ) @@ -224,7 +205,7 @@ def original_invoke(self, *args, **kwargs): assert invoke_span["attributes"][SPANDATA.GEN_AI_PIPELINE_NAME] == "test_graph" assert invoke_span["attributes"][SPANDATA.GEN_AI_AGENT_NAME] == "test_graph" - if send_default_pii and include_prompts: + if send_default_pii: assert SPANDATA.GEN_AI_REQUEST_MESSAGES in invoke_span["attributes"] assert SPANDATA.GEN_AI_RESPONSE_TEXT in invoke_span["attributes"] @@ -257,23 +238,17 @@ def original_invoke(self, *args, **kwargs): @pytest.mark.parametrize( - "send_default_pii, include_prompts", - [ - (True, True), - (True, False), - (False, True), - (False, False), - ], + "send_default_pii", + [True, False], ) def test_pregel_ainvoke( sentry_init, capture_items, send_default_pii, - include_prompts, ): """Test Pregel.ainvoke() async wrapper creates proper invoke_agent span.""" sentry_init( - integrations=[LanggraphIntegration(include_prompts=include_prompts)], + integrations=[LanggraphIntegration()], traces_sample_rate=1.0, send_default_pii=send_default_pii, ) @@ -327,7 +302,7 @@ async def run_test(): assert invoke_span["attributes"][SPANDATA.GEN_AI_PIPELINE_NAME] == "async_graph" assert invoke_span["attributes"][SPANDATA.GEN_AI_AGENT_NAME] == "async_graph" - if send_default_pii and include_prompts: + if send_default_pii: assert SPANDATA.GEN_AI_REQUEST_MESSAGES in invoke_span["attributes"] assert SPANDATA.GEN_AI_RESPONSE_TEXT in invoke_span["attributes"] @@ -357,7 +332,7 @@ def test_pregel_invoke_error( ): """Test error handling during graph execution.""" sentry_init( - integrations=[LanggraphIntegration(include_prompts=True)], + integrations=[LanggraphIntegration()], traces_sample_rate=1.0, send_default_pii=True, ) @@ -393,7 +368,7 @@ def test_pregel_ainvoke_error( ): """Test error handling during async graph execution.""" sentry_init( - integrations=[LanggraphIntegration(include_prompts=True)], + integrations=[LanggraphIntegration()], traces_sample_rate=1.0, send_default_pii=True, ) @@ -526,7 +501,7 @@ def test_extraction_functions_complex_scenario( ): """Test extraction functions with complex scenarios including multiple messages and edge cases.""" sentry_init( - integrations=[LanggraphIntegration(include_prompts=True)], + integrations=[LanggraphIntegration()], traces_sample_rate=1.0, send_default_pii=True, ) @@ -605,7 +580,7 @@ def test_langgraph_message_role_mapping( ): """Test that Langgraph integration properly maps message roles like 'ai' to 'assistant'""" sentry_init( - integrations=[LanggraphIntegration(include_prompts=True)], + integrations=[LanggraphIntegration()], traces_sample_rate=1.0, send_default_pii=True, )