Skip to content

Switch multi-tool execution from sequential to parallel with ThreadPoolExecutor#114

Closed
mlikasam-askui wants to merge 1 commit intomainfrom
enable-parallel-tool-run
Closed

Switch multi-tool execution from sequential to parallel with ThreadPoolExecutor#114
mlikasam-askui wants to merge 1 commit intomainfrom
enable-parallel-tool-run

Conversation

@mlikasam-askui
Copy link
Contributor

@mlikasam-askui mlikasam-askui commented Aug 8, 2025

During testing, running the tools in parallel was up to 9 seconds faster than running them sequentially.
Number of tools: 10
Sequential run: 13.5814 seconds
Parallel (threaded) run: 4.2600 seconds

Copy link
Contributor

@adi-wan-askui adi-wan-askui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome idea and simple implementation, long overdue :)

The only question I have is, how do we deal with tool calls in the message that are to be called sequentially, example:

Image

Comment on lines +168 to +169
if len(tool_use_content_blocks) == 0:
return None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about removing this? ThreadPoolExecutor.map() and, therefore, ToolCollection.run() can handle empty list.

@mlikasam-askui
Copy link
Contributor Author

@adi-wan-askui Great catch! I only tested this with my specific use case and didn't encounter that issue. I'd suggest closing this PR since we can't use it as-is. Parallel tool usage doesn't necessarily mean the tool executions themselves can be parallelized.

@mlikasam-askui mlikasam-askui deleted the enable-parallel-tool-run branch August 27, 2025 08:39
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.

2 participants