-
Notifications
You must be signed in to change notification settings - Fork 80
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
Add an Option to createReactAgent ToolNode for Sequential Tool Execution #303
Comments
Hey @VittorioYan, Would you pass the result of one tool back to the model in between executions? If so, you might find this guide helpful: https://js.langchain.com/v0.2/docs/how_to/tool_calling_parallel/ Could you give a clearer example of what you mean? |
@jacoblee93 Thank you for your prompt response. |
how would you expect the LLM to convey that it needs result from step 1 as input to step2? |
@hwchase17 You can understand what I'm doing like this: I have a form. I need to fill in the input first and then click the submit button. All operations on the form jointly maintain a state as the system prompt. |
We can discuss but for now you could always replace the prebuilt with a custom implementation like in the second example here: https://langchain-ai.github.io/langgraphjs/how-tos/tool-calling-errors/ |
Ya echoing this thread, it seems fairly straightforward to implement in your own graph but more error prone if we pushed this into Rewoo and llmcompiler (https://blog.langchain.dev/planning-agents/) are two examples of agents that do something similar to what you're discussing (create tool calls that reference previous ones), but the interfaces are different enough to not clearly share an abstraction |
Thank you very much for your response. I will try your approach. |
I still have a doubt . export type CreateReactAgentParams = {
llm: BaseChatModel;
tools:
| ToolNode<MessagesState>
| (StructuredToolInterface | RunnableToolLike)[];
messageModifier?:
| SystemMessage
| string
| ((messages: BaseMessage[]) => BaseMessage[])
| ((messages: BaseMessage[]) => Promise<BaseMessage[]>)
| Runnable;
checkpointSaver?: BaseCheckpointSaver;
interruptBefore?: N[] | All;
interruptAfter?: N[] | All;
}; Tools can transfer the ToolNode type, but in createReactAgent: const workflow = new StateGraph<AgentState>({
channels: schema,
})
.addNode(
"agent",
RunnableLambda.from(callModel).withConfig({ runName: "agent" })
)
.addNode("tools", new ToolNode<AgentState>(toolClasses))
.addEdge(START, "agent")
.addConditionalEdges("agent", shouldContinue, {
continue: "tools",
[END]: END,
})
.addEdge("tools", "agent"); addNode still add a new ToolNode. I feel that supporting the transfer of ToolNode doesn't make sense. |
Yeah you'll need to implement your own ToolNode equivalent with the desired behavior |
Yes, I originally intended to rewrite ToolNode and still use createReactAgent. However, when I checked the source code, I found that the rewritten ToolNode did not take effect because the built-in ToolNode was still being used here, only the tools from my ToolNode were used. |
Description:
Currently, the createReactAgent ToolNode executes tools in parallel, which is efficient for many use cases. However, there are scenarios where sequential execution is necessary, such as when the output of one tool is required as the input for the next tool in the sequence.
Feature Request
Add an option to the ToolNode in the createReactAgent that allows tools to be executed sequentially instead of in parallel. This could be implemented as a configuration option or as a separate method.
Thank you !
The text was updated successfully, but these errors were encountered: