|
6 | 6 |
|
7 | 7 | from sentry_sdk.integrations.openai_agents import OpenAIAgentsIntegration |
8 | 8 | from sentry_sdk.integrations.openai_agents.utils import safe_serialize |
| 9 | +from sentry_sdk.utils import parse_version |
9 | 10 |
|
10 | 11 | import agents |
11 | 12 | from agents import ( |
|
20 | 21 | ResponseOutputText, |
21 | 22 | ResponseFunctionToolCall, |
22 | 23 | ) |
| 24 | +from agents.version import __version__ as OPENAI_AGENTS_VERSION |
23 | 25 |
|
24 | 26 | from openai.types.responses.response_usage import ( |
25 | 27 | InputTokensDetails, |
@@ -438,24 +440,28 @@ def simple_test_tool(message: str) -> str: |
438 | 440 | ai_client_span2, |
439 | 441 | ) = spans |
440 | 442 |
|
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) |
459 | 465 |
|
460 | 466 | assert transaction["transaction"] == "test_agent workflow" |
461 | 467 | assert transaction["contexts"]["trace"]["origin"] == "auto.ai.openai_agents" |
|
0 commit comments