Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: ToolNode should support executing tools sequentially rather than in parallel. #861

Open
Altaflux opened this issue Feb 12, 2025 · 2 comments

Comments

@Altaflux
Copy link

Altaflux commented Feb 12, 2025

Problem:

I notice that when multiple tools are requested by the Agent the ToolNode node executes all tools in parallel. Although this might make execution time shorter it causes problems if the Agent is expecting the tools to execute on the specified order.

Keeping tool execution order the same as expected by the LLM is desired if the tools executed are against a stateful system.
This can be the case when working with: Databases, API's, Desktop/Browser manipulation, etc..

Example scenario I just encountered; I am building a tool-set for Desktop Control (how creative i know) and given a task the LLM will try to execute multiple tools at the same time.

  1. Move the mouse.
  2. Click on element.
  3. Type (text) on keyboard.
  4. Click Enter.

Tool calls as the above require that the tools get invoked on the order specified by the LLM.
Currently this is not possible as ToolNode will try to execute the tools parallelly and there is no telling which one will end first. Clicking Enter will probably finish faster than typing or moving the mouse.

Solution:

I believe that the ToolNode should have an option to force tool calls to happen sequentially, thus guaranteeing a predictable execution of the tasks, and also adds the guarantee that if one tool call fails subsequent tool calls will not be invoked which could further leave the target system of the tool calls on a broken state.

It may even be safer for ToolNode to execute tools sequentially as the default mode and parallel as the opt-in approach.

I have already implemented a version of ToolNode for my project to fit this change and it was quite easy to do so. I can create a PR with the change to ToolNode if this feature is liked.

@bags307
Copy link

bags307 commented Feb 17, 2025

@Altaflux could you do that? I have a similar need and would love to see what you did.

@Altaflux
Copy link
Author

@bags307 Here is my implementation:
https://github.com/Altaflux/agent-mimir/blob/16f41476b039cb01abe9874089af632aca3260e2/agent-mimir/src/tools/toolNode.ts
It should be a drop in replacement of Langgraph's Toolnode

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

No branches or pull requests

2 participants