Share Member Interactions

This example demonstrates how to enable sharing of member interactions within a team. When share_member_interactions is set to True, team members can see and build upon each other's responses, creating a collaborative workflow.

Create a Python file

1from kern.agent import Agent
2from kern.db.sqlite import SqliteDb
3from kern.models.openai import OpenAIResponses
4from kern.team import Team
5from kern.tools.hackernews import HackerNewsTools
6
7db = SqliteDb(db_file="tmp/agents.db")
8
9research_agent = Agent(
10 name="Research Agent",
11 model=OpenAIResponses(id="gpt-5.2"),
12 tools=[HackerNewsTools()],
13 instructions="You are a research agent that finds information on HackerNews.",
14)
15
16report_agent = Agent(
17 name="Report Agent",
18 model=OpenAIResponses(id="gpt-5.2"),
19 instructions="You are a report agent that writes reports from research.",
20)
21
22team = Team(
23 model=OpenAIResponses(id="gpt-5.2"),
24 db=db,
25 members=[research_agent, report_agent],
26 share_member_interactions=True,
27 instructions=[
28 "You are a team of agents that can research topics and write reports.",
29 "First, research the topic using HackerNews.",
30 "Then, use your report agent to write a report from the research.",
31 ],
32 show_members_responses=True,
33)
34
35team.print_response("What are the latest AI trends?", stream=True)

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

Export your OpenAI API key

Set OpenAI Key

Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.

1export OPENAI_API_KEY=sk-***
1setx OPENAI_API_KEY sk-***

Run Team

1python share_member_interactions.py