-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add cookbook notebook for parallel agents #1803
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
base: main
Are you sure you want to change the base?
Conversation
Adds a cookbook notebook demonstrating how to run agents in parallel, chain the output from parallel calls to another agent, and visualize the execution timeline of the agents.
a74d0c9
to
cc148ab
Compare
Hi, last week Eoin mentioned support for transforming agents into tools. I wonder if the same can be achieved using agents as tools + parallel tools calls e.g meta_agent = Agent(
name="MetaAgent",
instructions="You are given multiple summaries labeled with Features, ProsCons, Sentiment, and a Recommendation."
" Combine them into a concise executive summary of the product review with a 1-5 star rating for each summary area.",
model_settings=ModelSettings(
parallel_tool_calls=True
),
tools=[
features_agent.as_tool(
tool_name="features",
tool_description="Extract the key product features from the review.",
),
pros_cons_agent.as_tool(
tool_name="pros_cons",
tool_description="List the pros and cons mentioned in the review.",
),
sentiment_agent.as_tool(
tool_name="sentiment",
tool_description="Summarize the overall user sentiment from the review.",
),
recommend_agent.as_tool(
tool_name="recommend",
tool_description="State whether you would recommend this product and why.",
),
],
) |
Definitely think this is a potential approach (and probably the better choice when the agents are this simple). I was thinking this makes sense as a very simple demonstration of the pattern becoming useful when the agents are more complex (or your graph becomes more complex where you may want to partially fan out and combine across different layers), but open to debate on it |
Could also add this in as a another approach, and just present both of them |
Agree, I think the agent as tool approach its valid when there a 1:1 mapping with tool and agent, but for wider agent scenarios your approach is def more scalable, so maybe we can present both patterns. |
Added another example showing the agent as tool approach, calling out the tradeoffs between the two in 368fa9d |
Summary
Adds a cookbook notebook demonstrating how to run agents in parallel, chain the output from parallel calls to another agent, and visualize the execution timeline of the agents.
Motivation
Provides a very brief example of parallelizing agents, fanning out and in, and visualizing the execution timelines. Inspired by internal questions on basic parallelization patterns for agents
Timeline screenshot for reference:

For new content
When contributing new content, read through our contribution guidelines, and mark the following action items as completed:
We will rate each of these areas on a scale from 1 to 4, and will only accept contributions that score 3 or higher on all areas. Refer to our contribution guidelines for more details.