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

Open
opened 2026-02-15 17:16:42 -05:00 by yindo · 2 comments
Owner

Originally created by @Altaflux on GitHub (Feb 11, 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.

Originally created by @Altaflux on GitHub (Feb 11, 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.
yindo added the enhancement label 2026-02-15 17:16:42 -05:00
Author
Owner

@bags307 commented on GitHub (Feb 16, 2025):

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

@bags307 commented on GitHub (Feb 16, 2025): @Altaflux could you do that? I have a similar need and would love to see what you did.
Author
Owner

@Altaflux commented on GitHub (Feb 17, 2025):

@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

@Altaflux commented on GitHub (Feb 17, 2025): @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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#169