Performance with Memory Updates
Example showing how to evaluate performance when memory updates are involved.
Create a Python file
1"""Run `uv pip install openai kern-ai memory_profiler` to install dependencies."""23from kern.agent import Agent4from kern.db.sqlite import SqliteDb5from kern.eval.performance import PerformanceEval6from kern.models.openai import OpenAIResponses78# Memory creation requires a db to be provided9db = SqliteDb(db_file="tmp/memory.db")101112def run_agent():13 agent = Agent(14 model=OpenAIResponses(id="gpt-5.2"),15 system_message="Be concise, reply with one sentence.",16 db=db,17 update_memory_on_run=True,18 )1920 response = agent.run("My name is Tom! I'm 25 years old and I live in New York.")21 print(f"Agent response: {response.content}")2223 return response242526response_with_memory_updates_perf = PerformanceEval(27 name="Memory Updates Performance",28 func=run_agent,29 num_iterations=5,30 warmup_runs=0,31)3233if __name__ == "__main__":34 response_with_memory_updates_perf.run(print_results=True, print_summary=True)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 memory_profilerExport your OpenAI API key
1export OPENAI_API_KEY="your_openai_api_key_here"1$Env:OPENAI_API_KEY="your_openai_api_key_here"Run Agent
1python performance_with_memory.py