Skip to content

fix(tools): cancel and await sibling toolset discovery tasks on cancellation (#8384) - #8522

Open
Abdulrehman1978 wants to merge 1 commit into
google:mainfrom
Abdulrehman1978:fix/toolset-discovery-gather-or-cancel
Open

Abdulrehman1978 wants to merge 1 commit into
google:mainfrom
Abdulrehman1978:fix/toolset-discovery-gather-or-cancel

Conversation

@Abdulrehman1978

Copy link
Copy Markdown

Summary

During parallel toolset discovery in process_agent_tools(), plain asyncio.gather() did not cancel and await sibling get_tools() coroutines when one toolset listing raised asyncio.CancelledError. That allowed sibling discovery tasks to outlive Runner.run_async.

Fixes #8384

Changes

  • Wrap each _convert_tool_union_to_tools(...) call in asyncio.create_task() and await _gather_or_cancel(tasks) (from ._batch_executor) in process_agent_tools() (src/google/adk/flows/llm_flows/tools/_agent_tools.py), matching the parallel function-call execution path.
  • Add test_process_agent_tools_cancels_siblings_when_listing_cancels in tests/unittests/flows/llm_flows/test_tool_request_processors.py.

Testing

  • pytest tests/unittests/flows/llm_flows/test_tool_request_processors.py tests/unittests/flows/llm_flows/tools/test_batch_executor.py -q (30 passed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toolset discovery can outlive Runner.run_async after a sibling listing cancels itself

1 participant