Skip to content

Commit dcdeb8d

Browse files
truncate invoke agent attributes
1 parent 53a84ae commit dcdeb8d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

sentry_sdk/integrations/openai_agents/spans/invoke_agent.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
from sentry_sdk.consts import OP, SPANDATA
1111
from sentry_sdk.scope import should_send_default_pii
1212
from sentry_sdk.traces import StreamedSpan
13-
from sentry_sdk.tracing_utils import has_span_streaming_enabled
13+
from sentry_sdk.tracing_utils import (
14+
has_span_streaming_enabled,
15+
should_truncate_gen_ai_input,
16+
)
1417
from sentry_sdk.utils import safe_serialize
1518

1619
from ..consts import SPAN_ORIGIN
@@ -80,9 +83,9 @@ def invoke_agent_span(
8083
client = sentry_sdk.get_client()
8184
scope = sentry_sdk.get_current_scope()
8285
messages_data = (
83-
normalized_messages
84-
if client.options.get("stream_gen_ai_spans", False)
85-
else truncate_and_annotate_messages(normalized_messages, span, scope)
86+
truncate_and_annotate_messages(normalized_messages, span, scope)
87+
if should_truncate_gen_ai_input(client.options)
88+
else normalized_messages
8689
)
8790
if messages_data is not None:
8891
set_data_normalized(

0 commit comments

Comments
 (0)