From a427c6d285f04af481ca8e1cb52d368b773fde98 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Wed, 21 Jan 2026 19:10:53 +0100 Subject: [PATCH] feat(litellm): Set system instruction attribute --- sentry_sdk/integrations/litellm.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sentry_sdk/integrations/litellm.py b/sentry_sdk/integrations/litellm.py index 5ec079367e..cc1e0f3926 100644 --- a/sentry_sdk/integrations/litellm.py +++ b/sentry_sdk/integrations/litellm.py @@ -10,6 +10,7 @@ truncate_and_annotate_messages, transform_openai_content_part, ) +from sentry_sdk.ai._openai_completions_api import _get_system_instructions from sentry_sdk.consts import SPANDATA from sentry_sdk.integrations import DidNotEnable, Integration from sentry_sdk.scope import should_send_default_pii @@ -129,6 +130,15 @@ def _input_callback(kwargs: "Dict[str, Any]") -> None: else: # For chat, look for the 'messages' parameter messages = kwargs.get("messages", []) + + system_instructions = _get_system_instructions(messages) + set_data_normalized( + span, + SPANDATA.GEN_AI_SYSTEM_INSTRUCTIONS, + system_instructions, + unpack=False, + ) + if messages: scope = sentry_sdk.get_current_scope() messages = _convert_message_parts(messages)