Async Team with Tools
This example demonstrates how to create an async team with various tools for information gathering using multiple agents with different tools to gather comprehensive information asynchronously.
Code
1import asyncio23from kern.agent import Agent4from kern.models.openai import OpenAIResponses5from kern.team import Team6from kern.tools.hackernews import HackerNewsTools7from kern.tools.yfinance import YFinanceTools89# HackerNews agent10news_agent = Agent(11 name="News Agent",12 role="Search HackerNews for tech news",13 model=OpenAIResponses(id="gpt-5.2"),14 tools=[HackerNewsTools()],15 instructions=[16 "Find the latest tech news and discussions",17 ],18)1920# Finance agent21finance_agent = Agent(22 name="Finance Agent",23 role="Get stock prices and financial data",24 model=OpenAIResponses(id="gpt-5.2"),25 tools=[YFinanceTools()],26 instructions=[27 "Get stock prices and financial information",28 ],29)3031# Create the research team32research_team = Team(33 name="Research Team",34 model=OpenAIResponses(id="gpt-5.2"),35 members=[36 news_agent,37 finance_agent,38 ],39 markdown=True,40 instructions=[41 "You are a team that researches companies.",42 "Use the news agent to find recent discussions and the finance agent for stock data.",43 ],44 show_members_responses=True,45)4647if __name__ == "__main__":48 asyncio.run(49 research_team.aprint_response(50 "Research NVIDIA - get the current stock price and find any recent HackerNews discussions about the company.",51 stream=True,52 )53 )Usage
Create a Python file
Create async_team_with_tools.py with the code above.
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateInstall dependencies
1uv pip install -U kern-ai openai yfinanceExport your OpenAI API key
1export OPENAI_API_KEY="your_openai_api_key_here"1$Env:OPENAI_API_KEY="your_openai_api_key_here"Run Team
1python async_team_with_tools.py