This example demonstrates how to run multiple async agents concurrently using asyncio.gather() to generate research reports on different AI providers simultaneously.
import asynciofrom agno.agent import Agentfrom agno.models.openai import OpenAIChatfrom agno.tools.duckduckgo import DuckDuckGoToolsfrom rich.pretty import pprintproviders = ["openai", "anthropic", "ollama", "cohere", "google"]instructions = [ "Your task is to write a well researched report on AI providers.", "The report should be unbiased and factual.",]async def get_reports(): tasks = [] for provider in providers: agent = Agent( model=OpenAIChat(id="gpt-4"), instructions=instructions, tools=[DuckDuckGoTools()], ) tasks.append( agent.arun(f"Write a report on the following AI provider: {provider}") ) results = await asyncio.gather(*tasks) return resultsasync def main(): results = await get_reports() for result in results: print("************") pprint(result.content) print("************") print("\n")if __name__ == "__main__": asyncio.run(main())