Reliability with Teams

Example showing how to assert an Kern Team is making the expected tool calls.

Paused runs include requirements on the TeamRunOutput.

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.team import TeamRunOutput
7from kern.team.team import Team
8from kern.tools.yfinance import YFinanceTools
9
10team_member = Agent(
11 name="Stock Searcher",
12 model=OpenAIResponses(id="gpt-5.2"),
13 role="Searches the web for information on a stock.",
14 tools=[YFinanceTools(stock_price=True)],
15)
16
17team = Team(
18 name="Stock Research Team",
19 model=OpenAIResponses(id="gpt-5.2"),
20 members=[team_member],
21 markdown=True,
22 show_members_responses=True,
23)
24
25expected_tool_calls = [
26 "delegate_task_to_member", # Tool call used to delegate a task to a Team member
27 "get_current_stock_price", # Tool call used to get the current stock price of a stock
28]
29
30
31def evaluate_team_reliability():
32 response: TeamRunOutput = team.run("What is the current stock price of NVDA?")
33 evaluation = ReliabilityEval(
34 name="Team Reliability Evaluation",
35 team_response=response,
36 expected_tool_calls=expected_tool_calls,
37 )
38 result: Optional[ReliabilityResult] = evaluation.run(print_results=True)
39 if result:
40 result.assert_passed()
41
42
43if __name__ == "__main__":
44 evaluate_team_reliability()

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 yfinance

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 Team

1python reliability_with_teams.py