You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all,
I need you guidance, I have an agent that perform vector search and consist of various tools, What i want to achieve is that i want to access of output of one tool to another tool. There is option of using shared state but this can be tricky in case there is multiple instance of tool running.
Thanks,
Any help would be highly appreciated.
The text was updated successfully, but these errors were encountered:
Hi @kapil-huma,
If I got your idea right, you are asking agent to launch multiple copies of the same tool simultaneously and then pass their results into another tool.
I don't know your exact layout, but you might find this approach useful:
You can define a unique id for every tool call so you can differentiate their results later on. You can do that by either generating uid inside of a tool call or add a new parameter that would be defined by the agent or choose an existing one, if it's guaranteed to be unique.
You can then save the tool output into shared state as a dictionary, for example as a {"uid":"result"} pairs. Just don't forget to pull existing data from shared state first, append new results to it and then save. Otherwise, you'll overwrite existing data in shared state.
You can also technically save every result into separate shared state variable with its key being a uid. This way you can avoid potential race conditions, but it might be slightly less convenient to work with. A little tip if you do decide to do it this way: you can use self._shared_state.data to get entire shared state dictionary, which can ease up further processing.
Then you can pull all uids in the 2nd tool from shared state. If you want agent to be able to select some particular results of the tool calls, you can return uid of every tool call back to agent and add a new input to the 2nd tool that takes list of uids. You then simply iterate through the provided list, pulling results of tool calls that agent has selected.
Alternitavely, if tools output fairly small amount of data, you can just ask agent to aggregate results of multiple tools calls and paste it into the 2nd tool as an input
Hope that clarifies it a bit, if you need further help, just let me know!
Hi all,
I need you guidance, I have an agent that perform vector search and consist of various tools, What i want to achieve is that i want to access of output of one tool to another tool. There is option of using shared state but this can be tricky in case there is multiple instance of tool running.
Thanks,
Any help would be highly appreciated.
The text was updated successfully, but these errors were encountered: