Skip to content
Merged
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
32 changes: 19 additions & 13 deletions tests/integrations/openai_agents/test_openai_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.openai_agents import OpenAIAgentsIntegration
from sentry_sdk.integrations.openai_agents.utils import _set_input_data, safe_serialize
from sentry_sdk.utils import parse_version
from sentry_sdk.utils import parse_version, package_version

from openai import AsyncOpenAI
from agents.models.openai_responses import OpenAIResponsesModel
Expand All @@ -37,6 +37,8 @@
from agents.exceptions import MaxTurnsExceeded, ModelBehaviorError
from agents.version import __version__ as OPENAI_AGENTS_VERSION

OPENAI_VERSION = package_version("openai")

from openai.types.responses import (
ResponseCreatedEvent,
ResponseTextDeltaEvent,
Expand Down Expand Up @@ -1256,18 +1258,22 @@ def simple_test_tool(message: str) -> str:
assert ai_client_span1["data"]["gen_ai.usage.output_tokens"] == 5
assert ai_client_span1["data"]["gen_ai.usage.output_tokens.reasoning"] == 0
assert ai_client_span1["data"]["gen_ai.usage.total_tokens"] == 15
assert ai_client_span1["data"]["gen_ai.response.tool_calls"] == safe_serialize(
[
{
"arguments": '{"message": "hello"}',
"call_id": "call_123",
"name": "simple_test_tool",
"type": "function_call",
"id": "call_123",
"status": None,
}
]
)

tool_call = {
"arguments": '{"message": "hello"}',
"call_id": "call_123",
"name": "simple_test_tool",
"type": "function_call",
"id": "call_123",
"status": None,
}

if OPENAI_VERSION >= (2, 25, 0):
tool_call["namespace"] = None

assert json.loads(ai_client_span1["data"]["gen_ai.response.tool_calls"]) == [
tool_call
]

assert tool_span["description"] == "execute_tool simple_test_tool"
assert tool_span["data"]["gen_ai.agent.name"] == "test_agent"
Expand Down
Loading