Reliability with Multiple Tools

Example showing how to assert an Kern Agent is making multiple expected tool calls.

Create a Python file

1from typing import Optional
2
3from kern.agent import Agent
4from kern.eval.reliability import ReliabilityEval, ReliabilityResult
5from kern.models.openai import OpenAIResponses
6from kern.run.agent import RunOutput
7from kern.tools.calculator import CalculatorTools
8
9
10def multiply_and_exponentiate():
11 agent = Agent(
12 model=OpenAIResponses(id="gpt-5.2"),
13 tools=[CalculatorTools(add=True, multiply=True, exponentiate=True)],
14 )
15 response: RunOutput = agent.run(
16 "What is 10*5 then to the power of 2? do it step by step"
17 )
18 evaluation = ReliabilityEval(
19 name="Tool Calls Reliability",
20 agent_response=response,
21 expected_tool_calls=["multiply", "exponentiate"],
22 )
23 result: Optional[ReliabilityResult] = evaluation.run(print_results=True)
24 if result:
25 result.assert_passed()
26
27
28if __name__ == "__main__":
29 multiply_and_exponentiate()

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 openai kern-ai

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 Agent

1python reliability_with_multiple_tools.py