Skip to content

Commit edde9e5

Browse files
restore mixed branches of test_tool_execution_span_data_collection
1 parent 7ff6326 commit edde9e5

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

‎tests/integrations/openai_agents/test_openai_agents.py‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,6 @@ async def inner(tool, run_kwargs=None, **init_kwargs):
16491649
integrations=[OpenAIAgentsIntegration()],
16501650
disabled_integrations=[StdlibIntegration],
16511651
traces_sample_rate=1.0,
1652-
data_collection={},
16531652
**init_kwargs,
16541653
)
16551654

@@ -1691,6 +1690,53 @@ def simple_test_tool(message: str) -> str:
16911690
return simple_test_tool
16921691

16931692

1693+
@pytest.mark.parametrize(
1694+
"data_collection,expect_input,expect_output",
1695+
[
1696+
pytest.param(
1697+
{"gen_ai": {"inputs": True, "outputs": False}},
1698+
True,
1699+
False,
1700+
id="gen-ai-only-inputs-enabled",
1701+
),
1702+
pytest.param(
1703+
{"gen_ai": {"inputs": False, "outputs": True}},
1704+
False,
1705+
True,
1706+
id="gen-ai-only-outputs-enabled",
1707+
),
1708+
],
1709+
)
1710+
@pytest.mark.asyncio
1711+
async def test_tool_execution_span_data_collection(
1712+
run_tool_agent,
1713+
simple_test_tool,
1714+
data_collection,
1715+
expect_input,
1716+
expect_output,
1717+
):
1718+
init_kwargs = {}
1719+
if data_collection is not None:
1720+
init_kwargs["data_collection"] = data_collection
1721+
1722+
_, tool_span_data = await run_tool_agent(
1723+
simple_test_tool,
1724+
**init_kwargs,
1725+
)
1726+
1727+
if expect_input:
1728+
assert tool_span_data[SPANDATA.GEN_AI_TOOL_INPUT] == '{"message": "hello"}'
1729+
else:
1730+
assert SPANDATA.GEN_AI_TOOL_INPUT not in tool_span_data
1731+
1732+
if expect_output:
1733+
assert (
1734+
tool_span_data[SPANDATA.GEN_AI_TOOL_OUTPUT] == "Tool executed with: hello"
1735+
)
1736+
else:
1737+
assert SPANDATA.GEN_AI_TOOL_OUTPUT not in tool_span_data
1738+
1739+
16941740
@pytest.mark.asyncio
16951741
async def test_tool_execution_span_non_sensitive_data_always_set(
16961742
run_tool_agent,

0 commit comments

Comments
 (0)