AG-010Agent · Using toolslayaeval.ToolNecessity

Tool Necessity

Was calling a tool really needed here?

TASKWhat's the price?ALREADY KNOWSnothing yetSearchTool was needed
Simulation state:
When it passes

Needed — it knew nothing yet.

Threshold satisfied: evaluation score >= 0.50.

When it fails

Not needed — it already knew.

Violation detected: execution flagged for human review or fallback routing.

SDK Specification

ParameterValueDescription
ClassToolNecessityPython evaluator class in layaeval
Required Fields"task", "available_context", "tool_call"Arguments expected in the call signature
Default Threshold>= 0.50Passes when quality score is at or above this value
CategoryAgent EvaluationUsing tools (Right tool, right inputs, results actually used.)

Python Example

pip install layaeval
tool-necessity.py
1from layaeval import ToolNecessity
2
3metric = ToolNecessity(threshold=0.50) # passes at or above 0.50
4
5res = metric(
6 task="Book a hotel in Paris for 2 guests on Mar 4.",
7 available_context="No hotel data loaded yet.",
8 tool_call="search_hotels(city='Paris', date='2026-03-04', guests=2)",
9)
10
11print(res.passed, res.value, res.confidence)

Related Agent Checks

Other checks in Using tools

View all 42 checks →