Basic Team

A team of AI agents working together to research topics.

A basic team with two specialized agents:

  1. HackerNews Researcher - Gets trending stories from HackerNews
  2. Finance Agent - Gets stock prices and financial data

The team leader coordinates by delegating to the appropriate agent based on the user's request.

Create a Python file

1from kern.agent import Agent
2from kern.models.openai import OpenAIResponses
3from kern.team.team import Team
4from kern.tools.hackernews import HackerNewsTools
5from kern.tools.yfinance import YFinanceTools
6
7hn_researcher = Agent(
8 name="HackerNews Researcher",
9 model=OpenAIResponses(id="gpt-5.2"),
10 role="Gets trending stories from HackerNews.",
11 tools=[HackerNewsTools()],
12)
13
14finance_agent = Agent(
15 name="Finance Agent",
16 model=OpenAIResponses(id="gpt-5.2"),
17 role="Gets stock prices and financial data.",
18 tools=[YFinanceTools()],
19)
20
21team = Team(
22 name="Research Team",
23 model=OpenAIResponses(id="gpt-5.2"),
24 members=[hn_researcher, finance_agent],
25 instructions=[
26 "Delegate to the HackerNews Researcher for tech news and trends.",
27 "Delegate to the Finance Agent for stock prices and financial data.",
28 "Synthesize the results into a clear summary.",
29 ],
30 markdown=True,
31 show_members_responses=True,
32)
33
34team.print_response(
35 input="What are the top AI stories on HackerNews and how is NVDA doing?",
36 stream=True
37)

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Install dependencies

1uv pip install -U kern-ai openai yfinance

Export 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 basic_team.py