Skip to content

Commit 85abba8

Browse files
committed
fix openai_agents 0.3.3
1 parent 0cd6096 commit 85abba8

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

tests/integrations/openai_agents/test_openai_agents.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from sentry_sdk.integrations.openai_agents import OpenAIAgentsIntegration
88
from sentry_sdk.integrations.openai_agents.utils import safe_serialize
9+
from sentry_sdk.utils import parse_version
910

1011
import agents
1112
from agents import (
@@ -20,6 +21,7 @@
2021
ResponseOutputText,
2122
ResponseFunctionToolCall,
2223
)
24+
from agents.version import __version__ as OPENAI_AGENTS_VERSION
2325

2426
from openai.types.responses.response_usage import (
2527
InputTokensDetails,
@@ -438,24 +440,28 @@ def simple_test_tool(message: str) -> str:
438440
ai_client_span2,
439441
) = spans
440442

441-
available_tools = safe_serialize(
442-
[
443-
{
444-
"name": "simple_test_tool",
445-
"description": "A simple tool",
446-
"params_json_schema": {
447-
"properties": {"message": {"title": "Message", "type": "string"}},
448-
"required": ["message"],
449-
"title": "simple_test_tool_args",
450-
"type": "object",
451-
"additionalProperties": False,
452-
},
453-
"on_invoke_tool": "<function agents.tool.function_tool.<locals>._create_function_tool.<locals>._on_invoke_tool>",
454-
"strict_json_schema": True,
455-
"is_enabled": True,
456-
}
457-
]
458-
)
443+
available_tools = [
444+
{
445+
"name": "simple_test_tool",
446+
"description": "A simple tool",
447+
"params_json_schema": {
448+
"properties": {"message": {"title": "Message", "type": "string"}},
449+
"required": ["message"],
450+
"title": "simple_test_tool_args",
451+
"type": "object",
452+
"additionalProperties": False,
453+
},
454+
"on_invoke_tool": "<function agents.tool.function_tool.<locals>._create_function_tool.<locals>._on_invoke_tool>",
455+
"strict_json_schema": True,
456+
"is_enabled": True,
457+
}
458+
]
459+
if parse_version(OPENAI_AGENTS_VERSION) >= (0, 3, 3):
460+
available_tools[0].update(
461+
{"tool_input_guardrails": None, "tool_output_guardrails": None}
462+
)
463+
464+
available_tools = safe_serialize(available_tools)
459465

460466
assert transaction["transaction"] == "test_agent workflow"
461467
assert transaction["contexts"]["trace"]["origin"] == "auto.ai.openai_agents"

0 commit comments

Comments
 (0)