@@ -1400,9 +1400,10 @@ async def _drain_cancelled_tasks(
14001400 self ,
14011401 tasks : set [asyncio .Task [Any ]],
14021402 ) -> tuple [_FunctionToolFailure | None , set [asyncio .Task [Any ]]]:
1403- late_failure_sources : dict [asyncio .Task [Any ], _FunctionToolFailureSource ] = {
1404- task : "cancelled_teardown" for task in tasks
1405- }
1403+ late_failure_sources : dict [asyncio .Task [Any ], _FunctionToolFailureSource ] = dict .fromkeys (
1404+ tasks ,
1405+ "cancelled_teardown" ,
1406+ )
14061407 return await _drain_cancelled_function_tool_tasks (
14071408 pending_tasks = tasks ,
14081409 task_states = self .task_states ,
@@ -1415,9 +1416,9 @@ async def _wait_post_invoke_tasks(
14151416 self ,
14161417 tasks : set [asyncio .Task [Any ]],
14171418 ) -> tuple [_FunctionToolFailure | None , set [asyncio .Task [Any ]]]:
1418- post_invoke_failure_sources : dict [asyncio .Task [Any ], _FunctionToolFailureSource ] = {
1419- task : "post_invoke" for task in tasks
1420- }
1419+ post_invoke_failure_sources : dict [asyncio .Task [Any ], _FunctionToolFailureSource ] = (
1420+ dict . fromkeys ( tasks , "post_invoke" )
1421+ )
14211422 return await _wait_pending_function_tool_tasks_for_timeout (
14221423 pending_tasks = tasks ,
14231424 task_states = self .task_states ,
@@ -1638,7 +1639,7 @@ async def _invoke_tool_and_run_post_invoke(
16381639 arguments = tool_call .arguments ,
16391640 )
16401641 except asyncio .CancelledError as e :
1641- if not self . isolate_parallel_failures or outer_task in self .teardown_cancelled_tasks :
1642+ if outer_task in self .teardown_cancelled_tasks :
16421643 raise
16431644
16441645 result = await maybe_invoke_function_tool_failure_error_function (
0 commit comments