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

Problem with Accessing output of one tool to other #211

Open
kapil-huma opened this issue Jan 8, 2025 · 2 comments
Open

Problem with Accessing output of one tool to other #211

kapil-huma opened this issue Jan 8, 2025 · 2 comments
Labels

Comments

@kapil-huma
Copy link

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.

@ArtemShatokhin
Copy link
Contributor

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:

  1. 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.
  2. 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.
  3. 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!

Copy link
Contributor

This issue is stale because it has been open for 30 days with no activity. Please upgrade to the latest version and test it again.

@github-actions github-actions bot added the stale label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants