Find answers from the community

Updated 4 weeks ago

Parallel and sequential execution of agents in agent workflows

Hi, I am trying to build a multi agent scenario where I want to invoke few agents in parallel and a few others sequentially. In Workflows, concurrent execution of workflows is supported, but I wanted to ask if this is possible using the Agents (via AgentWorkflow)?
L
w
s
10 comments
Use agents as tools for other agents
Thats the main way to achieve it when using AgentWorkflow
ooc, whats the actual use case/structure you are looking to implement?
Trying to understand better of agents as tools is enough to support this or not
Thanks for the response @Logan M

I want to run a quick PoC for an e-commerce workflow using a multi-agent approach. Here's the idea:

A WorkflowAgent acts as the entry point when a user initiates a request.
It first invokes a UserProfileAgent to handle authentication & authorization.
Once verified, the WorkflowAgent triggers multiple specialized agents in parallel (where possible) to handle different tasks:
ProductReviewAgent (fetches & summarizes reviews)
ProductSummaryAgent (retrieves/generates product details)
ReturnsProcessingAgent (handles return requests)
Any other relevant agents we might need.

Since there's no dependency between these specialized agents, we can execute them in parallel for efficiency. The WorkflowAgent will then aggregate responses and return the final result.
Neat. Yea to me, putting your agents as tools for other agents makes the most sense here
Hi Logan.
I wanted to ask that according to what you are saying, in the above implementation the data_agent will execute its tools in parallel ?
Attachment
image.png
Yes, assuming that those tools are properly async and that the llm is smart enough to chose more than one tool at a given time
So I've tried to test out parallel execution of tools by the agent, but despite making the functions async, setting the allow_parallel_tool_calls=True and explicitly mentioning in the prompt of the agent to execute the tools in parallel, it still somehow doesnt show any parallel execution.

Here's a small example https://colab.research.google.com/drive/1re9tYWhydPadKsLY8FzazaTqqGj0xI3Y#scrollTo=OcGi4mmrEq1j.
I've used this tutorial and notebook provided by LlamaIndex as a baseline to create the parallel execution example
Can you have a quick look and let me know whether I'm missing something ?
you need to use async achat()

I also thought we were talking about AgentWorkflow? But anyways, I updated the notebook with async and it works fine. I also sanity tested AgentWorkflow and it also works fine
https://colab.research.google.com/drive/1kff0ja_ToGb__8IlB8Dm_f3_UqilWpY_?usp=sharing
Add a reply
Sign up and join the conversation on Discord