Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,12 @@ class SPANDATA:
Example: 2048
"""

GEN_AI_SYSTEM_INSTRUCTIONS = "gen_ai.system_instructions"
"""
The system instructions passed to the model.
Example: [{"type": "text", "text": "You are a helpful assistant."},{"type": "text", "text": "Be concise and clear."}]
"""

GEN_AI_REQUEST_MESSAGES = "gen_ai.request.messages"
"""
The messages passed to the model. The "content" can be a string or an array of objects.
Expand Down
7 changes: 2 additions & 5 deletions sentry_sdk/integrations/openai_agents/spans/invoke_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ def invoke_agent_span(
if isinstance(agent.instructions, str)
else safe_serialize(agent.instructions)
)
messages.append(
{
"content": [{"text": message, "type": "text"}],
"role": "system",
}
set_data_normalized(
span, SPANDATA.GEN_AI_SYSTEM_INSTRUCTIONS, message, unpack=False
)

original_input = kwargs.get("original_input")
Expand Down
10 changes: 4 additions & 6 deletions tests/integrations/openai_agents/test_openai_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,12 @@ async def test_agent_invocation_span(
assert transaction["contexts"]["trace"]["origin"] == "auto.ai.openai_agents"

assert invoke_agent_span["description"] == "invoke_agent test_agent"
assert (
invoke_agent_span["data"][SPANDATA.GEN_AI_SYSTEM_INSTRUCTIONS]
== "You are a helpful test assistant."
)
assert invoke_agent_span["data"]["gen_ai.request.messages"] == safe_serialize(
[
{
"content": [
{"text": "You are a helpful test assistant.", "type": "text"}
],
"role": "system",
},
{"content": [{"text": "Test input", "type": "text"}], "role": "user"},
]
)
Expand Down
Loading