Parallel Workflow
Execute independent tasks simultaneously to reduce total execution time.
Before running the example, set the OpenAI key in the same terminal:
export OPENAI_API_KEY="your_openai_api_key"Use Parallel to run independent steps at the same time. When steps don't depend on
each other's output, running them in parallel reduces total execution time.
When to use: Independent tasks that contribute to the same final goal, such as research from multiple sources or parallel data processing.
Install dependencies:
uv pip install agno openai yfinancefrom agno.agent import Agent
from agno.tools.hackernews import HackerNewsTools
from agno.tools.yfinance import YFinanceTools
from agno.workflow import Step, Workflow
from agno.workflow.parallel import Parallel
# Create agents
news_researcher = Agent(name="News Researcher", tools=[HackerNewsTools()])
finance_researcher = Agent(name="Finance Researcher", tools=[YFinanceTools()])
writer = Agent(name="Writer")
reviewer = Agent(name="Reviewer")
# Create individual steps
research_news_step = Step(name="Research News", agent=news_researcher)
research_finance_step = Step(name="Research Finance", agent=finance_researcher)
write_step = Step(name="Write Article", agent=writer)
review_step = Step(name="Review Article", agent=reviewer)
# Create workflow with parallel research
workflow = Workflow(
name="Content Creation Pipeline",
steps=[
Parallel(research_news_step, research_finance_step, name="Research Phase"),
write_step,
review_step,
],
)
workflow.print_response("Write about the latest AI developments and stock trends")