Team Streaming

Stream responses from a team in real-time.

Stream responses from a team with stream=True for real-time output as the team works.

Create a Python file

1from kern.agent import Agent
2from kern.models.openai import OpenAIResponses
3from kern.team import Team
4from kern.tools.hackernews import HackerNewsTools
5from kern.tools.yfinance import YFinanceTools
6
7news_agent = Agent(
8 name="News Agent",
9 model=OpenAIResponses(id="gpt-5.2"),
10 role="Gets trending tech 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=[news_agent, finance_agent],
25 markdown=True,
26 show_members_responses=True,
27)
28
29# Stream the response
30team.print_response(
31 "What are the trending AI stories and how is NVDA stock doing?",
32 stream=True,
33)

Resolve each item in active_requirements, then call continue_run() or acontinue_run() on the team to resume.

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 streaming_team.py