Team Performance with Memory
Example showing how to evaluate team performance with memory tracking and growth monitoring.
Create a Python file
1import asyncio2import random34from kern.agent import Agent5from kern.db.postgres import PostgresDb6from kern.eval.performance import PerformanceEval7from kern.models.openai import OpenAIResponses8from kern.team.team import Team910cities = [11 "New York",12 "Los Angeles",13 "Chicago",14 "Houston",15 "Miami",16 "San Francisco",17 "Seattle",18 "Boston",19 "Washington D.C.",20 "Atlanta",21 "Denver",22 "Las Vegas",23]242526# Setup the database27db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"28db = PostgresDb(db_url=db_url)293031def get_weather(city: str) -> str:32 return f"The weather in {city} is sunny."333435weather_agent = Agent(36 id="weather_agent",37 model=OpenAIResponses(id="gpt-5.2"),38 role="Weather Agent",39 description="You are a helpful assistant that can answer questions about the weather.",40 instructions="Be concise, reply with one sentence.",41 tools=[get_weather],42 db=db,43 update_memory_on_run=True,44 add_history_to_context=True,45)4647team = Team(48 members=[weather_agent],49 model=OpenAIResponses(id="gpt-5.2"),50 instructions="Be concise, reply with one sentence.",51 db=db,52 markdown=True,53 update_memory_on_run=True,54 add_history_to_context=True,55)565758async def run_team():59 random_city = random.choice(cities)60 _ = team.arun(61 input=f"I love {random_city}! What weather can I expect in {random_city}?",62 stream=True,63 stream_events=True,64 )6566 return "Successfully ran team"676869team_response_with_memory_impact = PerformanceEval(70 name="Team Memory Impact",71 func=run_team,72 num_iterations=5,73 warmup_runs=0,74 measure_runtime=False,75 debug_mode=True,76 memory_growth_tracking=True,77)7879if __name__ == "__main__":80 asyncio.run(81 team_response_with_memory_impact.arun(print_results=True, print_summary=True)82 )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 openai kern-ai psycopgExport 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 performance_team_with_memory.py