Skip to content
Merged
Changes from 1 commit
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
77 changes: 45 additions & 32 deletions tests/integrations/openai_agents/test_openai_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,38 +1220,37 @@
)
tool_span = next(span for span in spans if span["op"] == OP.GEN_AI_EXECUTE_TOOL)

available_tools = [
{
"name": "simple_test_tool",
"description": "A simple tool",
"params_json_schema": {
"properties": {"message": {"title": "Message", "type": "string"}},
"required": ["message"],
"title": "simple_test_tool_args",
"type": "object",
"additionalProperties": False,
},
"on_invoke_tool": mock.ANY,
"strict_json_schema": True,
"is_enabled": True,
}
]
available_tool = {
"name": "simple_test_tool",
"description": "A simple tool",
"params_json_schema": {
"properties": {"message": {"title": "Message", "type": "string"}},
"required": ["message"],
"title": "simple_test_tool_args",
"type": "object",
"additionalProperties": False,
},
"on_invoke_tool": mock.ANY,
"strict_json_schema": True,
"is_enabled": True,
}

if parse_version(OPENAI_AGENTS_VERSION) >= (0, 3, 3):
available_tools[0].update(
available_tool.update(
{"tool_input_guardrails": None, "tool_output_guardrails": None}
)

if parse_version(OPENAI_AGENTS_VERSION) >= (
0,
8,
):
available_tools[0]["needs_approval"] = False
available_tool["needs_approval"] = False
if parse_version(OPENAI_AGENTS_VERSION) >= (
0,
9,
0,
):
available_tools[0].update(
available_tool.update(
{
"timeout_seconds": None,
"timeout_behavior": "error_as_result",
Expand All @@ -1266,10 +1265,14 @@
assert agent_span["origin"] == "auto.ai.openai_agents"
assert agent_span["data"]["gen_ai.agent.name"] == "test_agent"
assert agent_span["data"]["gen_ai.operation.name"] == "invoke_agent"
assert (
json.loads(agent_span["data"]["gen_ai.request.available_tools"])
== available_tools

agent_span_available_tools = json.loads(
agent_span["data"]["gen_ai.request.available_tools"]
)[0]
assert all(
agent_span_available_tools.get(k) == v for k, v in available_tool.items()
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
)

assert agent_span["data"]["gen_ai.request.max_tokens"] == 100
assert agent_span["data"]["gen_ai.request.model"] == "gpt-4"
assert agent_span["data"]["gen_ai.request.temperature"] == 0.7
Expand All @@ -1280,10 +1283,14 @@
assert ai_client_span1["data"]["gen_ai.operation.name"] == "chat"
assert ai_client_span1["data"]["gen_ai.system"] == "openai"
assert ai_client_span1["data"]["gen_ai.agent.name"] == "test_agent"
assert (
json.loads(ai_client_span1["data"]["gen_ai.request.available_tools"])
== available_tools

ai_client_span1_available_tools = json.loads(
tool_span["data"]["gen_ai.request.available_tools"]

Check warning on line 1288 in tests/integrations/openai_agents/test_openai_agents.py

View workflow job for this annotation

GitHub Actions / warden: find-bugs

Test validates wrong span data due to copy-paste error

On line 1288, the code reads from `tool_span["data"]["gen_ai.request.available_tools"]` but the variable name `ai_client_span1_available_tools` and the context (assertions about `ai_client_span1` follow) indicate it should read from `ai_client_span1`. The original code correctly used `ai_client_span1["data"]["gen_ai.request.available_tools"]`. This means the test no longer validates the available_tools data for `ai_client_span1`, weakening test coverage.
)[0]

Check warning on line 1289 in tests/integrations/openai_agents/test_openai_agents.py

View workflow job for this annotation

GitHub Actions / warden: code-review

Test validates wrong span data - reads from tool_span instead of ai_client_span1

The variable `ai_client_span1_available_tools` is supposed to validate data from `ai_client_span1` (as indicated by its name and the surrounding assertions on lines 1282-1285 that check `ai_client_span1` properties), but it reads from `tool_span["data"]` instead. This means the test doesn't actually verify that `ai_client_span1` has the correct `gen_ai.request.available_tools` data, making the test ineffective for validating the AI client span.
Comment thread
alexander-alderman-webb marked this conversation as resolved.
assert all(
ai_client_span1_available_tools.get(k) == v for k, v in available_tool.items()
)

assert ai_client_span1["data"]["gen_ai.request.max_tokens"] == 100
assert ai_client_span1["data"]["gen_ai.request.messages"] == safe_serialize(
[
Expand Down Expand Up @@ -1323,10 +1330,12 @@
assert tool_span["description"] == "execute_tool simple_test_tool"
assert tool_span["data"]["gen_ai.agent.name"] == "test_agent"
assert tool_span["data"]["gen_ai.operation.name"] == "execute_tool"
assert (
json.loads(agent_span["data"]["gen_ai.request.available_tools"])
== available_tools
)

tool_span_available_tools = json.loads(
tool_span["data"]["gen_ai.request.available_tools"]
)[0]
assert all(tool_span_available_tools.get(k) == v for k, v in available_tool.items())

assert tool_span["data"]["gen_ai.request.max_tokens"] == 100
assert tool_span["data"]["gen_ai.request.model"] == "gpt-4"
assert tool_span["data"]["gen_ai.request.temperature"] == 0.7
Expand All @@ -1341,10 +1350,14 @@
assert ai_client_span2["description"] == "chat gpt-4"
assert ai_client_span2["data"]["gen_ai.agent.name"] == "test_agent"
assert ai_client_span2["data"]["gen_ai.operation.name"] == "chat"
assert (
json.loads(agent_span["data"]["gen_ai.request.available_tools"])
== available_tools

ai_client_span2_available_tools = json.loads(
tool_span["data"]["gen_ai.request.available_tools"]
)[0]

Check warning on line 1356 in tests/integrations/openai_agents/test_openai_agents.py

View workflow job for this annotation

GitHub Actions / warden: code-review

[UCW-XQS] Test validates wrong span data - reads from tool_span instead of ai_client_span1 (additional location)

The variable `ai_client_span1_available_tools` is supposed to validate data from `ai_client_span1` (as indicated by its name and the surrounding assertions on lines 1282-1285 that check `ai_client_span1` properties), but it reads from `tool_span["data"]` instead. This means the test doesn't actually verify that `ai_client_span1` has the correct `gen_ai.request.available_tools` data, making the test ineffective for validating the AI client span.

Check warning on line 1356 in tests/integrations/openai_agents/test_openai_agents.py

View workflow job for this annotation

GitHub Actions / warden: find-bugs

[9XM-WW2] Test validates wrong span data due to copy-paste error (additional location)

On line 1288, the code reads from `tool_span["data"]["gen_ai.request.available_tools"]` but the variable name `ai_client_span1_available_tools` and the context (assertions about `ai_client_span1` follow) indicate it should read from `ai_client_span1`. The original code correctly used `ai_client_span1["data"]["gen_ai.request.available_tools"]`. This means the test no longer validates the available_tools data for `ai_client_span1`, weakening test coverage.
assert all(
ai_client_span2_available_tools.get(k) == v for k, v in available_tool.items()
)

assert ai_client_span2["data"]["gen_ai.request.max_tokens"] == 100
assert ai_client_span2["data"]["gen_ai.request.messages"] == safe_serialize(
[
Expand Down
Loading