Skip to content

Commit d077633

Browse files
committed
improve
1 parent 86ee824 commit d077633

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

sentry_sdk/integrations/openai_agents/spans/invoke_agent.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from sentry_sdk.ai.utils import set_data_normalized
33
from sentry_sdk.consts import OP, SPANDATA
44
from sentry_sdk.scope import should_send_default_pii
5+
from sentry_sdk.utils import safe_serialize
56

67
from ..consts import SPAN_ORIGIN
78
from ..utils import _set_agent_data
@@ -29,15 +30,20 @@ def invoke_agent_span(context, agent, kwargs):
2930
if agent.instructions:
3031
messages.append(
3132
{
32-
"content": [{"text": agent.instructions, "type": "text"}],
33+
"content": [
34+
{"text": safe_serialize(agent.instructions), "type": "text"}
35+
],
3336
"role": "system",
3437
}
3538
)
3639

37-
if "original_input" in kwargs and kwargs["original_input"] is not None:
40+
original_input = kwargs.get("original_input")
41+
if original_input is not None:
3842
messages.append(
3943
{
40-
"content": [{"text": kwargs["original_input"], "type": "text"}],
44+
"content": [
45+
{"text": safe_serialize(original_input), "type": "text"}
46+
],
4147
"role": "user",
4248
}
4349
)

0 commit comments

Comments
 (0)