Skip to content

Commit 67e9344

Browse files
chore: Replace deprecated gen_ai.tool.input with gen_ai.tool.call.arguments
1 parent ad13d87 commit 67e9344

7 files changed

Lines changed: 38 additions & 23 deletions

File tree

‎sentry_sdk/integrations/google_genai/utils.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ async def async_wrapped(*args: "Any", **kwargs: "Any") -> "Any":
710710
tool_input = _capture_tool_input(args, kwargs, tool)
711711
with capture_internal_exceptions():
712712
span.set_attribute(
713-
SPANDATA.GEN_AI_TOOL_INPUT, safe_serialize(tool_input)
713+
SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS, safe_serialize(tool_input)
714714
)
715715

716716
try:
@@ -737,7 +737,7 @@ def sync_wrapped(*args: "Any", **kwargs: "Any") -> "Any":
737737
tool_input = _capture_tool_input(args, kwargs, tool)
738738
with capture_internal_exceptions():
739739
span.set_attribute(
740-
SPANDATA.GEN_AI_TOOL_INPUT, safe_serialize(tool_input)
740+
SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS, safe_serialize(tool_input)
741741
)
742742

743743
try:

‎sentry_sdk/integrations/langchain.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ def on_tool_start(
735735

736736
set_data_normalized(
737737
span,
738-
SPANDATA.GEN_AI_TOOL_INPUT,
738+
SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS,
739739
kwargs.get("inputs", [input_str]),
740740
)
741741

‎sentry_sdk/integrations/openai_agents/patches/runner.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def on_tool_start(
5757
if not client.options["data_collection"]["gen_ai"]["inputs"]:
5858
return
5959

60-
span.set_attribute(SPANDATA.GEN_AI_TOOL_INPUT, context.tool_arguments)
60+
span.set_attribute(SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS, context.tool_arguments)
6161

6262
async def on_tool_end(
6363
self,

‎sentry_sdk/integrations/pydantic_ai/spans/execute_tool.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def execute_tool_span(
5353
):
5454
return span
5555

56-
span.set_attribute(SPANDATA.GEN_AI_TOOL_INPUT, safe_serialize(tool_args))
56+
span.set_attribute(SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS, safe_serialize(tool_args))
5757

5858
return span
5959

‎tests/integrations/langchain/test_langchain.py‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ def test_tool_execution_span(
913913
chat_spans[1]["attributes"][SPANDATA.GEN_AI_RESPONSE_MODEL] == "gpt-4-0613"
914914
)
915915

916-
assert "word" in tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_INPUT]
916+
assert "word" in tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS]
917917

918918
assert "5" in chat_spans[1]["attributes"][SPANDATA.GEN_AI_RESPONSE_TEXT]
919919

@@ -1088,7 +1088,9 @@ def test_tool_execution_span_no_sensitive_data(
10881088
assert SPANDATA.GEN_AI_RESPONSE_TEXT not in chat_spans[0].get("attributes", {})
10891089
assert SPANDATA.GEN_AI_REQUEST_MESSAGES not in chat_spans[1].get("attributes", {})
10901090
assert SPANDATA.GEN_AI_RESPONSE_TEXT not in chat_spans[1].get("attributes", {})
1091-
assert SPANDATA.GEN_AI_TOOL_INPUT not in tool_exec_span.get("attributes", {})
1091+
assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS not in tool_exec_span.get(
1092+
"attributes", {}
1093+
)
10921094
assert SPANDATA.GEN_AI_TOOL_OUTPUT not in tool_exec_span.get("attributes", {})
10931095

10941096
assert SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS not in chat_spans[0].get(
@@ -1264,7 +1266,7 @@ def test_langchain_openai_tools_agent(
12641266
)
12651267

12661268
assert "5" in chat_spans[0]["attributes"][SPANDATA.GEN_AI_RESPONSE_TEXT]
1267-
assert "word" in tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_INPUT]
1269+
assert "word" in tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS]
12681270
assert 5 == int(tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_OUTPUT])
12691271

12701272
assert json.loads(
@@ -1434,7 +1436,9 @@ def test_langchain_openai_tools_agent_no_sensitive_data(
14341436
)
14351437
assert SPANDATA.GEN_AI_REQUEST_MESSAGES not in chat_spans[1].get("attributes", {})
14361438
assert SPANDATA.GEN_AI_RESPONSE_TEXT not in chat_spans[1].get("attributes", {})
1437-
assert SPANDATA.GEN_AI_TOOL_INPUT not in tool_exec_span.get("attributes", {})
1439+
assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS not in tool_exec_span.get(
1440+
"attributes", {}
1441+
)
14381442
assert SPANDATA.GEN_AI_TOOL_OUTPUT not in tool_exec_span.get("attributes", {})
14391443

14401444
assert SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS not in chat_spans[0].get(
@@ -1659,7 +1663,9 @@ def test_langchain_openai_tools_agent_stream_no_sensitive_data(
16591663
)
16601664
assert SPANDATA.GEN_AI_REQUEST_MESSAGES not in chat_spans[1].get("attributes", {})
16611665
assert SPANDATA.GEN_AI_RESPONSE_TEXT not in chat_spans[1].get("attributes", {})
1662-
assert SPANDATA.GEN_AI_TOOL_INPUT not in tool_exec_span.get("attributes", {})
1666+
assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS not in tool_exec_span.get(
1667+
"attributes", {}
1668+
)
16631669
assert SPANDATA.GEN_AI_TOOL_OUTPUT not in tool_exec_span.get("attributes", {})
16641670

16651671
assert SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS not in chat_spans[0].get(
@@ -1847,7 +1853,7 @@ def test_langchain_openai_tools_agent_stream(
18471853
)
18481854

18491855
assert "5" in chat_spans[0]["attributes"][SPANDATA.GEN_AI_RESPONSE_TEXT]
1850-
assert "word" in tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_INPUT]
1856+
assert "word" in tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS]
18511857
assert 5 == int(tool_exec_span["attributes"][SPANDATA.GEN_AI_TOOL_OUTPUT])
18521858

18531859
assert json.loads(
@@ -3358,14 +3364,14 @@ def test_langchain_data_collection_request_tool_call_params(
33583364
[
33593365
pytest.param(
33603366
{"gen_ai": {"inputs": True, "outputs": False}},
3361-
{SPANDATA.GEN_AI_TOOL_INPUT: {"word": "eudca"}},
3367+
{SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS: {"word": "eudca"}},
33623368
[SPANDATA.GEN_AI_TOOL_OUTPUT],
33633369
id="gen-ai-inputs-enabled-outputs-disabled",
33643370
),
33653371
pytest.param(
33663372
{"gen_ai": {"inputs": False, "outputs": True}},
33673373
{SPANDATA.GEN_AI_TOOL_OUTPUT: 5},
3368-
[SPANDATA.GEN_AI_TOOL_INPUT],
3374+
[SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS],
33693375
id="gen-ai-outputs-enabled-inputs-disabled",
33703376
),
33713377
],

‎tests/integrations/openai_agents/test_openai_agents.py‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,7 +1375,10 @@ async def test_tool_execution_span(
13751375
assert tool_span["attributes"]["gen_ai.request.top_p"] == 1.0
13761376
assert tool_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
13771377
assert tool_span["attributes"]["gen_ai.tool.description"] == "A simple tool"
1378-
assert tool_span["attributes"]["gen_ai.tool.input"] == '{"message": "hello"}'
1378+
assert (
1379+
tool_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS]
1380+
== '{"message": "hello"}'
1381+
)
13791382
assert tool_span["attributes"]["gen_ai.tool.name"] == "simple_test_tool"
13801383
assert tool_span["attributes"]["gen_ai.tool.output"] == "Tool executed with: hello"
13811384
assert ai_client_span2["name"] == "chat gpt-4"
@@ -1578,7 +1581,10 @@ async def test_run_streamed_tool_execution_span(
15781581
assert tool_span["attributes"]["gen_ai.request.top_p"] == 1.0
15791582
assert tool_span["attributes"][SPANDATA.GEN_AI_PROVIDER_NAME] == "openai"
15801583
assert tool_span["attributes"]["gen_ai.tool.description"] == "A simple tool"
1581-
assert tool_span["attributes"]["gen_ai.tool.input"] == '{"message": "hello"}'
1584+
assert (
1585+
tool_span["attributes"][SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS]
1586+
== '{"message": "hello"}'
1587+
)
15821588
assert tool_span["attributes"]["gen_ai.tool.name"] == "simple_test_tool"
15831589
assert tool_span["attributes"]["gen_ai.tool.output"] == "Tool executed with: hello"
15841590

@@ -1725,9 +1731,12 @@ async def test_tool_execution_span_data_collection(
17251731
)
17261732

17271733
if expect_input:
1728-
assert tool_span_data[SPANDATA.GEN_AI_TOOL_INPUT] == '{"message": "hello"}'
1734+
assert (
1735+
tool_span_data[SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS]
1736+
== '{"message": "hello"}'
1737+
)
17291738
else:
1730-
assert SPANDATA.GEN_AI_TOOL_INPUT not in tool_span_data
1739+
assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS not in tool_span_data
17311740

17321741
if expect_output:
17331742
assert (

‎tests/integrations/pydantic_ai/test_pydantic_ai.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def add_numbers(a: int, b: int) -> int:
419419
assert "execute_tool" in tool_span["name"]
420420
assert tool_span["attributes"]["gen_ai.operation.name"] == "execute_tool"
421421
assert tool_span["attributes"]["gen_ai.tool.name"] == "add_numbers"
422-
assert "gen_ai.tool.input" in tool_span["attributes"]
422+
assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS in tool_span["attributes"]
423423
assert "gen_ai.tool.output" in tool_span["attributes"]
424424

425425
# Check chat spans have available_tools
@@ -505,13 +505,13 @@ def add_numbers(a: int, b: int) -> float:
505505
model_retry_tool_span["attributes"]["gen_ai.operation.name"] == "execute_tool"
506506
)
507507
assert model_retry_tool_span["attributes"]["gen_ai.tool.name"] == "add_numbers"
508-
assert "gen_ai.tool.input" in model_retry_tool_span["attributes"]
508+
assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS in model_retry_tool_span["attributes"]
509509

510510
tool_span = tool_spans[1]
511511
assert "execute_tool" in tool_span["name"]
512512
assert tool_span["attributes"]["gen_ai.operation.name"] == "execute_tool"
513513
assert tool_span["attributes"]["gen_ai.tool.name"] == "add_numbers"
514-
assert "gen_ai.tool.input" in tool_span["attributes"]
514+
assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS in tool_span["attributes"]
515515
assert "gen_ai.tool.output" in tool_span["attributes"]
516516

517517
# Check chat spans have available_tools
@@ -636,7 +636,7 @@ def multiply(a: int, b: int) -> int:
636636
# Check tool span
637637
tool_span = tool_spans[0]
638638
assert tool_span["attributes"]["gen_ai.tool.name"] == "multiply"
639-
assert "gen_ai.tool.input" in tool_span["attributes"]
639+
assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS in tool_span["attributes"]
640640
assert "gen_ai.tool.output" in tool_span["attributes"]
641641

642642

@@ -873,7 +873,7 @@ def sensitive_tool(data: str) -> str:
873873

874874
# If tool was executed, verify input/output are not captured
875875
for tool_span in tool_spans:
876-
assert "gen_ai.tool.input" not in tool_span["attributes"]
876+
assert SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS not in tool_span["attributes"]
877877
assert "gen_ai.tool.output" not in tool_span["attributes"]
878878

879879

@@ -3080,7 +3080,7 @@ def add_numbers(a: int, b: int) -> int:
30803080
# sent, so the assertion does not depend on the test model's defaults.
30813081
tool_span = tool_spans[0]
30823082
assert SPANDATA.GEN_AI_TOOL_OUTPUT not in tool_span
3083-
tool_input = json.loads(tool_span[SPANDATA.GEN_AI_TOOL_INPUT])
3083+
tool_input = json.loads(tool_span[SPANDATA.GEN_AI_TOOL_CALL_ARGUMENTS])
30843084
expected_tool_return = str(tool_input["a"] + tool_input["b"])
30853085

30863086
tool_messages = [

0 commit comments

Comments
 (0)