@@ -1152,10 +1152,10 @@ def regular_tool(x: int) -> int:
11521152 assert isinstance (response , DeferredToolRequests )
11531153 assert len (response .calls ) == 1
11541154 assert response .calls [0 ].tool_name == 'deferred_tool'
1155- # Check metadata exists for this tool_call_id
1155+ # When no metadata is provided, the tool_call_id should not be in metadata dict
11561156 tool_call_id = response .calls [0 ].tool_call_id
1157- assert tool_call_id in response .metadata
1158- assert response .metadata [ tool_call_id ] == {}
1157+ assert tool_call_id not in response .metadata
1158+ assert response .metadata == {}
11591159 messages = result .all_messages ()
11601160
11611161 # Verify no tools were called
@@ -1639,18 +1639,10 @@ def my_tool(x: int) -> int:
16391639 async with agent .run_stream ('Hello' ) as result :
16401640 assert not result .is_complete
16411641 assert [c async for c in result .stream_output (debounce_by = None )] == snapshot (
1642- [
1643- DeferredToolRequests (
1644- calls = [ToolCallPart (tool_name = 'my_tool' , args = {'x' : 0 }, tool_call_id = IsStr ())],
1645- metadata = {'pyd_ai_tool_call_id__my_tool' : {}},
1646- )
1647- ]
1642+ [DeferredToolRequests (calls = [ToolCallPart (tool_name = 'my_tool' , args = {'x' : 0 }, tool_call_id = IsStr ())])]
16481643 )
16491644 assert await result .get_output () == snapshot (
1650- DeferredToolRequests (
1651- calls = [ToolCallPart (tool_name = 'my_tool' , args = {'x' : 0 }, tool_call_id = IsStr ())],
1652- metadata = {'pyd_ai_tool_call_id__my_tool' : {}},
1653- )
1645+ DeferredToolRequests (calls = [ToolCallPart (tool_name = 'my_tool' , args = {'x' : 0 }, tool_call_id = IsStr ())])
16541646 )
16551647 responses = [c async for c , _is_last in result .stream_responses (debounce_by = None )]
16561648 assert responses == snapshot (
@@ -1665,10 +1657,7 @@ def my_tool(x: int) -> int:
16651657 ]
16661658 )
16671659 assert await result .validate_response_output (responses [0 ]) == snapshot (
1668- DeferredToolRequests (
1669- calls = [ToolCallPart (tool_name = 'my_tool' , args = {'x' : 0 }, tool_call_id = IsStr ())],
1670- metadata = {'pyd_ai_tool_call_id__my_tool' : {}},
1671- )
1660+ DeferredToolRequests (calls = [ToolCallPart (tool_name = 'my_tool' , args = {'x' : 0 }, tool_call_id = IsStr ())])
16721661 )
16731662 assert result .usage () == snapshot (RunUsage (requests = 1 , input_tokens = 51 , output_tokens = 0 ))
16741663 assert result .timestamp () == IsNow (tz = timezone .utc )
@@ -1695,10 +1684,7 @@ def my_tool(ctx: RunContext[None], x: int) -> int:
16951684 messages = result .all_messages ()
16961685 output = await result .get_output ()
16971686 assert output == snapshot (
1698- DeferredToolRequests (
1699- approvals = [ToolCallPart (tool_name = 'my_tool' , args = '{"x": 1}' , tool_call_id = IsStr ())],
1700- metadata = {'my_tool' : {}},
1701- )
1687+ DeferredToolRequests (approvals = [ToolCallPart (tool_name = 'my_tool' , args = '{"x": 1}' , tool_call_id = IsStr ())])
17021688 )
17031689 assert result .is_complete
17041690
@@ -1873,7 +1859,6 @@ def my_other_tool(x: int) -> int:
18731859 DeferredToolRequests (
18741860 calls = [ToolCallPart (tool_name = 'my_tool' , args = {'x' : 0 }, tool_call_id = IsStr ())],
18751861 approvals = [ToolCallPart (tool_name = 'my_other_tool' , args = {'x' : 0 }, tool_call_id = IsStr ())],
1876- metadata = {'pyd_ai_tool_call_id__my_tool' : {}, 'pyd_ai_tool_call_id__my_other_tool' : {}},
18771862 )
18781863 )
18791864
0 commit comments