File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121from sentry_sdk .integrations import DidNotEnable , Integration
2222from sentry_sdk .scope import should_send_default_pii
2323from sentry_sdk .tracing_utils import _get_value , set_span_errored
24- from sentry_sdk .utils import capture_internal_exceptions , logger
24+ from sentry_sdk .utils import capture_internal_exceptions , logger , safe_repr
2525
2626if TYPE_CHECKING :
2727 from typing import (
@@ -688,7 +688,9 @@ def on_tool_end(
688688 span = span_data .span
689689
690690 if should_send_default_pii () and self .include_prompts :
691- set_data_normalized (span , SPANDATA .GEN_AI_TOOL_OUTPUT , output )
691+ set_data_normalized (
692+ span , SPANDATA .GEN_AI_TOOL_OUTPUT , safe_repr (output )
693+ )
692694
693695 self ._exit_span (span_data , run_id )
694696
Original file line number Diff line number Diff line change 11import sentry_sdk
22from sentry_sdk .consts import OP , SPANDATA , SPANSTATUS
33from sentry_sdk .scope import should_send_default_pii
4+ from sentry_sdk .utils import safe_repr
45
56from ..consts import SPAN_ORIGIN
67from ..utils import _set_agent_data
@@ -47,7 +48,7 @@ def update_execute_tool_span(
4748 span .set_status (SPANSTATUS .INTERNAL_ERROR )
4849
4950 if should_send_default_pii ():
50- span .set_data (SPANDATA .GEN_AI_TOOL_OUTPUT , result )
51+ span .set_data (SPANDATA .GEN_AI_TOOL_OUTPUT , safe_repr ( result ) )
5152
5253 # Add conversation ID from agent
5354 conv_id = getattr (agent , "_sentry_conversation_id" , None )
Original file line number Diff line number Diff line change 1212from sentry_sdk .integrations import DidNotEnable
1313from sentry_sdk .scope import should_send_default_pii
1414from sentry_sdk .tracing_utils import set_span_errored
15- from sentry_sdk .utils import event_from_exception , safe_serialize
15+ from sentry_sdk .utils import event_from_exception , safe_serialize , safe_repr
1616from sentry_sdk .ai ._openai_completions_api import _transform_system_instructions
1717from sentry_sdk .ai ._openai_responses_api import (
1818 _is_system_instruction ,
@@ -231,7 +231,7 @@ def _create_mcp_execute_tool_spans(
231231 SPANDATA .GEN_AI_TOOL_INPUT , output .arguments
232232 )
233233 execute_tool_span .set_data (
234- SPANDATA .GEN_AI_TOOL_OUTPUT , output .output
234+ SPANDATA .GEN_AI_TOOL_OUTPUT , safe_repr ( output .output )
235235 )
236236 if output .error :
237237 execute_tool_span .set_status (SPANSTATUS .INTERNAL_ERROR )
You can’t perform that action at this time.
0 commit comments