Async Reliability Evaluation
Example showing how to run reliability evaluations asynchronously.
Create a Python file
1"""This example shows how to run a Reliability evaluation asynchronously."""23import asyncio4from typing import Optional56from kern.agent import Agent7from kern.eval.reliability import ReliabilityEval, ReliabilityResult8from kern.models.openai import OpenAIResponses9from kern.run.agent import RunOutput10from kern.tools.calculator import CalculatorTools111213def factorial():14 agent = Agent(15 model=OpenAIResponses(id="gpt-5.2"),16 tools=[CalculatorTools()],17 )18 response: RunOutput = agent.run("What is 10!?")19 evaluation = ReliabilityEval(20 agent_response=response,21 expected_tool_calls=["factorial"],22 )2324 # Run the evaluation calling the arun method.25 result: Optional[ReliabilityResult] = asyncio.run(26 evaluation.arun(print_results=True)27 )28 if result:29 result.assert_passed()303132if __name__ == "__main__":33 factorial()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-aiExport 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 reliability_async.py