conditional routing depending on tool output to next tool #1340
Unanswered
streamnsight
asked this question in
Q&A
Replies: 1 comment
-
Does this guide provide any help? https://langchain-ai.github.io/langgraph/how-tos/human_in_the_loop/review-tool-calls/ It walks through a few different scenarios of human-in-the-loop interactions for confirming or changing tool calls, which seems to be what you want. Let me know if this wasn't what you were looking for. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm trying to figure how to do conditional routing between tools. Maybe there is another way, or better pattern, so let me explain.
Let's say I want the user to provide a prompt.
Depending on prompt, a single tool should be used, or maybe a chain of tools. The agent defines that. Or maybe I know I need to call a tool ,but I need to do something else before I can run the tool.
What I need is, depending on the output of the first tool, I need to branch out to a 'subgraph' of some sort, to perform some task, to then come back to the next tool.
That doesn't seem to be possible as once the tool calls are passed to the tool node, it tries to run those in a sequence.
I tried splitting things, have a first tool define an output and then have conditional edges look at that and redirect, but the next tool call gets lost, unless I hack it to propagate it through the chain of the other nodes.
an example would be:
I ask the agent to write a summary of some user's history, naming the user by name.
The agent will determine it needs the 'write summary' tool, which takes a 'name' arg.
However, the name is usually not so precise, I need to look up a user Id from the name, and there are many cases: there may be multiple users with the same name, or whatever, I need the user to intervene and confirm the user, then pass the Id to the tool.
The tool takes the name arg so I can get the name for the Id check, but the id then reside in state and the 'name' arg is not used, rather the id is pulled from state. Again that seems hacky.
So I could have a tool check user Id by name, and then a tool doing summary by id. The agent is able to chain those, but I can't find an easy way to branch out of the first tool to have the user confirm the id.
Is there a better way to do this?
Beta Was this translation helpful? Give feedback.
All reactions