Skip to content

feat: enable parallel tool execution in ToolInvoker#9530

Merged
Amnah199 merged 17 commits intomainfrom
add-async-tool-invoker
Jun 25, 2025
Merged

feat: enable parallel tool execution in ToolInvoker#9530
Amnah199 merged 17 commits intomainfrom
add-async-tool-invoker

Conversation

@Amnah199
Copy link
Copy Markdown
Contributor

@Amnah199 Amnah199 commented Jun 18, 2025

Related Issues

Proposed Changes:

  • Update run_async to gather all tool_calls and execute them in parallel.

How did you test it?

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I documented my code
  • I ran pre-commit hooks and fixed any issue

@github-actions github-actions Bot added the type:documentation Improvements on the docs label Jun 18, 2025
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Jun 18, 2025

Pull Request Test Coverage Report for Build 15872972654

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 84 unchanged lines in 10 files lost coverage.
  • Overall coverage increased (+0.09%) to 90.278%

Files with Coverage Reduction New Missed Lines %
components/rankers/sentence_transformers_similarity.py 1 98.75%
components/generators/hugging_face_api.py 2 96.43%
components/routers/init.py 2 46.15%
dataclasses/init.py 2 23.08%
dataclasses/streaming_chunk.py 5 91.53%
components/generators/chat/openai.py 6 96.39%
components/generators/utils.py 9 75.0%
components/generators/chat/hugging_face_api.py 10 94.79%
utils/base_serialization.py 18 89.09%
components/tools/tool_invoker.py 29 87.76%
Totals Coverage Status
Change from base Build 15728854337: 0.09%
Covered Lines: 11709
Relevant Lines: 12970

💛 - Coveralls

@Amnah199 Amnah199 changed the title Enable parallel tool execution in ToolInvoker feat: enable parallel tool execution in ToolInvoker Jun 18, 2025
Comment thread haystack/components/tools/tool_invoker.py Outdated
Comment thread haystack/components/tools/tool_invoker.py Outdated
@Amnah199 Amnah199 requested a review from mpangrazzi June 20, 2025 11:08
Copy link
Copy Markdown
Contributor

@mpangrazzi mpangrazzi left a comment

Choose a reason for hiding this comment

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

Looks generally good, I've added a few comments!

Comment thread haystack/components/tools/tool_invoker.py Outdated
Comment thread haystack/components/tools/tool_invoker.py Outdated
Comment thread haystack/components/tools/tool_invoker.py Outdated
@Amnah199 Amnah199 marked this pull request as ready for review June 22, 2025 22:48
@Amnah199 Amnah199 requested review from a team as code owners June 22, 2025 22:48
@Amnah199 Amnah199 requested review from anakin87 and dfokina and removed request for a team and anakin87 June 22, 2025 22:48
Comment thread haystack/components/tools/tool_invoker.py Outdated
Comment thread haystack/components/tools/tool_invoker.py Outdated
@sjrl
Copy link
Copy Markdown
Contributor

sjrl commented Jun 24, 2025

@Amnah199 as a general comment could we align the implementations of run and run_async to match as closely as possible? I realize they can't exactly be the same, but it would be great if we could minimize the differences so they are easier to both update at the same time in the future. For example, self._prepare_tool_call_params is called before the ThreadPoolExecutor context in run but it is called inside of the context in run_async.

Comment thread haystack/components/tools/tool_invoker.py Outdated
@Amnah199 Amnah199 requested review from mpangrazzi and sjrl June 25, 2025 09:46
Copy link
Copy Markdown
Contributor

@sjrl sjrl left a comment

Choose a reason for hiding this comment

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

Thanks looks good!

@Amnah199 Amnah199 merged commit 1cd0a12 into main Jun 25, 2025
19 checks passed
@Amnah199 Amnah199 deleted the add-async-tool-invoker branch June 25, 2025 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate running Tools in Parallel in the ToolInvoker

5 participants