DeepEval 4.3 agent metrics in depth: tool checks, permission gates, loop detection, G-Eval
DeepEval 4.3.4 ships more than a dozen agent metrics, and several need no LLM at all. This guide runs four of them offline on a refund agent, shows the exact formulas behind each score, and explains why a loop that obviously failed still passed with default settings.
- Reading time
- 13 min
- Sections
- 9
- Code examples
- 12
- Tables
- 1
- Sources
- 6
- Published
- 23 Nov 2026
- What happened
- The test case: one refund request, three tool calls
- Metric 1: ToolCorrectnessMetric, and why it misses the deletion
- Metric 2: ToolPermissionMetric as a least-privilege gate
- Metric 3: AgentLoopDetectionMetric on a stuck agent
- Metric 4: G-Eval with an offline judge
- What it means in practice
- What to do now
- What changed
- DeepEval 4.3.0 released
- Why it matters
- A sound agent test suite in DeepEval has layers.
- What to do
- Pin 4.3.4
DeepEval is an open-source evaluation framework that works like a unit test library for LLM applications. You build a test case that holds the input, the output and, for agents, the tools that were called. You attach metrics that score the test case between 0 and 1. A metric passes when its score reaches a threshold.
For agents, the interesting part of DeepEval 4.3 is the split between two kinds of metrics. Some ask a judge model for an opinion: was the task completed, was the plan sensible? Others are plain algorithms: which expected tools were called, were any forbidden tools used, did the agent repeat itself? The second kind costs nothing, gives the same answer every time and can block a merge in CI.
This article runs four metrics against one refund agent scenario, entirely offline, with deepeval==4.3.4 on Python 3.13. For the metric that needs a judge, we plug in a scripted judge model so you can see the exact data flow without an API key. Every score below is copied from our runs.
What happened
DeepEval 4.3.0 released (15 October 2026)
The 4.3 line started on 15 October, the same day as 4.2.9. Comparing the metric classes exported by 4.2.9 and 4.3.4, we found the same list in both, so the agent metrics described here were already present when 4.3 began.
DeepEval 4.3.4 is the current release (11 November 2026)
The latest patch, 4.3.4, was published on 11 November after 4.3.2 (27 October) and 4.3.3 (4 November). Its deepeval.metrics module exports metrics for single-turn answers, RAG, conversations, images, voice and agents. The agent group includes TaskCompletionMetric, ToolCorrectnessMetric, ArgumentCorrectnessMetric, ToolPermissionMetric, AgentLoopDetectionMetric, StepEfficiencyMetric, PlanQualityMetric, PlanAdherenceMetric, GoalAccuracyMetric, ToolUseMetric and MCP-specific metrics such as MCPUseMetric.
Judge-based metrics accept three evaluation modes
Many metric constructors in 4.3.4 take eval_mode with the values "llm", "hybrid" and "system_one", plus a system_one_model. The base class describes a system one model as one that "answers typed questions about a state with calibrated probabilities instead of generating text", used "for the decision step only; extraction and reasons stay on the LLM".
The test case: one refund request, three tool calls
An agent was asked to refund order A-42 and email the customer. It looked up the order, issued the refund, and then, wrongly, deleted the customer record. It never sent the email.
pip install "deepeval==4.3.4"
export DEEPEVAL_TELEMETRY_OPT_OUT=1 # optional: no usage telemetry
from deepeval.test_case import LLMTestCase, ToolCall
case = LLMTestCase(
input="Refund order A-42 and email the customer.",
actual_output="Refund issued and customer emailed.",
tools_called=[
ToolCall(name="lookup_order", input_parameters={"order_id": "A-42"}),
ToolCall(name="issue_refund", input_parameters={"order_id": "A-42", "amount": 120}),
ToolCall(name="delete_customer", input_parameters={"customer_id": "C-7"}),
],
expected_tools=[
ToolCall(name="lookup_order"), ToolCall(name="issue_refund"), ToolCall(name="send_email"),
],
)
Notice the final answer claims an email was sent. A judge reading only the answer might be fooled. The tool record tells the truth. That is the main reason to evaluate agents on their trajectory, the sequence of actions, not only on their words.
Metric 1: ToolCorrectnessMetric, and why it misses the deletion
Even when it does not call a judge, ToolCorrectnessMetric initialises a model in its constructor, and the default is OpenAI, which fails without an API key. So we pass our offline judge (shown in full in the G-Eval section below); it is never called because we do not supply available_tools.
from deepeval.metrics import ToolCorrectnessMetric
tc = ToolCorrectnessMetric(threshold=0.7, model=ScriptedJudge(), async_mode=False)
tc.measure(case)
print(round(tc.score, 3), tc.success)
0.667 False
The default formula, read from the 4.3.4 source, works like matching guests to a guest list. For each expected tool, it looks for an unmatched called tool with the same name and type. Each match scores 1. The total is divided by the number of expected tools.
lookup_order: matched, 1.issue_refund: matched, 1.send_email: no match, 0.- Score: 2 divided by 3, which is 0.667. Below 0.7, so it fails.
Here is the catch: delete_customer does not lower the score at all. The formula counts what is missing, not what is extra. Options change this behaviour:
| Option | Effect |
|---|---|
should_exact_match=True |
Score is 1 only if the called list equals the expected list in length, order and names; otherwise 0 |
should_consider_ordering=True |
Uses a weighted longest common subsequence divided by the expected count |
evaluation_params=[ToolCallParams.INPUT_PARAMETERS] |
Also compares arguments, multiplying each match by a dictionary similarity |
available_tools=[...] |
Adds an LLM check of whether the right tools were chosen; the final score is the minimum of both parts |
Exact match would have scored 0, which is honest here but too strict for agents that may legitimately call a tool twice. The better fix is a second metric that looks for forbidden actions.
Metric 2: ToolPermissionMetric as a least-privilege gate
ToolPermissionMetric ignores whether the task was solved. It checks every call against an allowlist and a denylist, and "a denial always wins over an allow". The score is the fraction of calls that were authorised, and the default threshold is 1.0, so a single unauthorised call fails the test. No model is needed.
from deepeval.metrics import ToolPermissionMetric
perm = ToolPermissionMetric(allowed_tools=["lookup_order", "issue_refund", "send_email"],
denied_tools=["delete_customer"])
perm.measure(case)
print(round(perm.score, 3), perm.success)
print(perm.reason)
0.667 False
1 of 3 tool call(s) were unauthorized: ['delete_customer']. Allowed=['issue_refund', 'lookup_order', 'send_email'], Denied=['delete_customer'].
Same number, different meaning: one third of the actions were not allowed. Paired with tool correctness, you now know both what the agent failed to do and what it should never have done. Permission metrics are a test-time check, not a runtime control; you still need runtime permissions, covered in the guardrails simulation.
Metric 3: AgentLoopDetectionMetric on a stuck agent
Loops are the most expensive agent failure because every repeated turn re-sends the growing context. AgentLoopDetectionMetric is "fully deterministic", needs no API key, and combines three signals:
- Tool repetition: identical
(name, args)calls. With the defaultrepetition_threshold=3, the sub-score drops to 0.5 at three repeats and to 0.0 at six. - Reasoning stagnation: consecutive LLM outputs compared with bigram Jaccard similarity and
difflib.SequenceMatcher, after removing stop words, againstsimilarity_threshold=0.85. - Call graph cycles: the same span label repeated on one root-to-leaf path.
The source combines them with weights of 0.40, 0.35 and 0.25. The metric reads the trace that DeepEval's @observe decorator records. To show the arithmetic, we set that trace by hand:
from deepeval.metrics import AgentLoopDetectionMetric
def tool(q): return {"type": "tool", "name": "search_docs", "input": {"query": q}, "output": "no results", "children": []}
def llm(text): return {"type": "llm", "name": "planner", "input": "plan", "output": text, "children": []}
trace = {"type": "agent", "name": "support_agent", "input": {"q": "refund rules?"}, "children": [
llm("I will search the docs for the refund policy."), tool("refund policy"),
llm("Let me search the docs for the refund policy again."), tool("refund policy"),
llm("I will now search the docs for the refund policy."), tool("refund policy"),
llm("Searching the docs for the refund policy."), tool("refund policy"),
]}
stuck = LLMTestCase(input="What are the refund rules?", actual_output="I could not find it.")
stuck._trace_dict = trace # normally filled in by @observe
m = AgentLoopDetectionMetric(async_mode=False)
m.measure(stuck)
print(round(m.score, 3), m.success, m.score_breakdown)
0.8 True {'tool_repetition': 0.5, 'reasoning_stagnation': 1.0, 'call_graph_cycles': 1.0}
Worked out: 0.40 × 0.5 + 0.35 × 1.0 + 0.25 × 1.0 = 0.8. The agent searched for the same thing four times and passed, because the default threshold is 0.5. The planner rephrased itself each time, so the wording stayed under the 0.85 similarity line, and the spans were siblings, not nested, so no cycle was found. Treat this as a calibration lesson: for loop detection, set the threshold to 0.9 or higher, or gate on the tool_repetition sub-score directly.
Continue learning
How this article connects
8 pages link to or from it. Drag to turn, click a dot to open it.
- Evals
- LLM-as-judge
- DeepEval
- Function calling (tool use)
- Agent evaluation step by step: trajectory matching, LLM judges, pass^k a
- Building an agentic AI system from scratch with LangGraph, Langfuse, Dee
- An agentic workflow end to end: build, guard, trace, evaluate and deploy
- RAG evaluation step by step: recall@k, MRR, nDCG, faithfulness and when
Metric 4: G-Eval with an offline judge
G-Eval is DeepEval's general LLM-as-judge metric. You write criteria in plain English. The judge first turns the criteria into evaluation steps, then scores the test case against those steps on a 0 to 10 scale, and DeepEval normalises the score to 0 to 1.
Any judge can be used by subclassing DeepEvalBaseLLM and implementing four methods: load_model, generate, a_generate and get_model_name. When a metric passes a Pydantic schema, the judge must return an instance of it. Our scripted judge looks up a canned reply by schema name, which makes the data flow visible:
import json
from deepeval.models import DeepEvalBaseLLM
class ScriptedJudge(DeepEvalBaseLLM):
def __init__(self, replies=None):
self.replies = replies or {}
super().__init__(model="scripted-judge")
def load_model(self):
return self
def _reply(self, prompt, schema):
name = schema.__name__ if schema is not None else "text"
data = self.replies.get(name, {"reason": "scripted", "score": 8})
if schema is not None:
return schema(**{k: v for k, v in data.items() if k in schema.model_fields})
return json.dumps(data)
def generate(self, prompt: str, schema=None):
return self._reply(prompt, schema)
async def a_generate(self, prompt: str, schema=None):
return self._reply(prompt, schema)
def get_model_name(self):
return "scripted-judge"
from deepeval.metrics import GEval
from deepeval.test_case import SingleTurnParams
judge = ScriptedJudge(replies={
"Steps": {"steps": ["Check the reply states the refund amount.",
"Check the reply gives a timeline.",
"Penalise promises the policy does not support."]},
"ReasonScore": {"reason": "States 120 EUR and a 3 to 5 day timeline.", "score": 9},
})
quality = GEval(
name="Refund reply quality",
criteria="Does the reply state the refund amount, give a realistic timeline and avoid unsupported promises?",
evaluation_params=[SingleTurnParams.INPUT, SingleTurnParams.ACTUAL_OUTPUT],
model=judge, threshold=0.7, async_mode=False,
)
quality.measure(LLMTestCase(input="Where is my refund for A-42?",
actual_output="We refunded 120 EUR today; banks take 3 to 5 business days."))
print(quality.score, quality.success)
0.9 True
The two schema names, Steps and ReasonScore, are the two judge calls G-Eval makes: one to write the steps, one to score. A raw 9 out of 10 becomes 0.9. In production you replace the scripted judge with a real model, and you should check how often it agrees with human graders; the judge agreement simulation shows why a judge with 80 percent agreement can still flip conclusions.
What it means in practice
A sound agent test suite in DeepEval has layers. Deterministic metrics (permission, tool correctness, loop detection) run on every commit because they are free and stable. Judge metrics (G-Eval, task completion, plan quality) run nightly or before release because they cost money and vary a little between runs. Both read the same test cases, so you build the dataset once.
Our runs also show that default thresholds are not neutral. A 0.5 threshold let a four-times-repeated search pass. Tool correctness ignored a destructive extra call. Read the formula before trusting the number, the same advice that applies to any evaluation metric.
Repetition matters as much as thresholds. An agent that passes a test case once may fail it on the next run, because sampling and tool results vary. Run each case several times and report both "passed at least once" and "passed every time"; the pass@k versus pass^k simulation shows how far apart those two numbers can be for the same agent. Loops deserve their own budget line too: the agent loop token cost simulation shows how four repeated searches multiply input tokens, which is why a loop metric that passes at 0.8 can still hide a real cost problem. Finally, remember that tool metrics only see what your function calling layer records. If arguments are not logged, ToolCallParams.INPUT_PARAMETERS has nothing to compare, and if your judge does the grading, the usual LLM-as-judge caveats about position bias and self-preference apply.
For how these metrics fit into a full build with tracing and RAG scoring, see building an agentic system with LangGraph, Langfuse, DeepEval and RAGAS, and the DeepEval tool page.
What to do now
- Pin 4.3.4. Install
deepeval==4.3.4and setDEEPEVAL_TELEMETRY_OPT_OUT=1if your policy forbids usage telemetry. - Record tool calls in every test case. Fill
tools_calledfrom your traces, with arguments, so trajectory metrics have data. - Add a permission gate. Use
ToolPermissionMetricwith an allowlist and a denylist of destructive tools, threshold 1.0. - Pair correctness with permissions. Tool correctness measures what is missing; permissions catch what is extra.
- Tighten loop detection. Raise
AgentLoopDetectionMetricthresholds or assert onscore_breakdown["tool_repetition"]. - Use a scripted judge in unit tests. Subclass
DeepEvalBaseLLMso tests of your evaluation code run without network calls. - Calibrate real judges. Score 50 to 100 examples by hand, compare with the judge, and only then set G-Eval thresholds.
- Run judge metrics with repetitions. Average several runs per case before comparing two agent versions.
Risks and open questions
Constructors may need a model even when scoring does not. ToolCorrectnessMetric failed at construction without an OpenAI key in our test. Always pass an explicit model in CI.
Formulas reward the wrong thing if misread. Extra destructive calls do not lower tool correctness by default.
Hand-built traces are for learning. We set _trace_dict directly, which is a private attribute. In real use, let @observe fill it.
Judge metrics drift with judge versions. A provider update can shift G-Eval scores without any change in your agent. Pin judge model versions and keep a calibration set.
Watch next: how eval_mode="system_one" and calibrated decision models change cost and stability of judge metrics, and whether loop detection gains a semantic mode.
Frequently asked questions
Which DeepEval metrics work without an LLM?
In 4.3.4, ToolPermissionMetric and AgentLoopDetectionMetric are documented as fully deterministic. ToolCorrectnessMetric scores deterministically unless you pass available_tools, but its constructor still initialises a model.
Why did ToolCorrectness ignore the delete call?
Its default score is matched expected tools divided by the number of expected tools. Extra calls are not counted. Use should_exact_match or a permission metric to catch them.
How does G-Eval produce a score?
It asks the judge to turn your criteria into steps, then asks it to score the test case on a 0 to 10 scale using those steps. DeepEval divides by 10 to get a 0 to 1 score.
Can I use my own model as the judge?
Yes. Subclass DeepEvalBaseLLM, implement load_model, generate, a_generate and get_model_name, and return schema instances when a schema is passed.
Where does the loop detection trace come from?
DeepEval's @observe decorator records spans for your agent, tools and LLM calls into a nested trace. The metric reads that trace; it does not look at the final answer.
Summary
DeepEval 4.3.4 gives agent builders a mix of deterministic and judge-based metrics. Running four of them offline on one bad refund shows how each works: tool correctness scored 0.667 because one expected tool was missing but ignored a destructive extra call; the permission metric caught that call with the same 0.667 but a different meaning; loop detection scored a four-times-repeated search 0.8 and passed under the default 0.5 threshold; and G-Eval turned a judge's 9 out of 10 into 0.9. Use deterministic metrics as CI gates, calibrate judge metrics before trusting them, and always read the formula behind a score.
Sources
Cite this article
Kelahmet, Ö. C. (2026, November 23). DeepEval 4.3 agent metrics in depth: tool checks, permission gates, loop detection, G-Eval. Özer Cem KELAHMET. https://www.ozercemkelahmet.com/articles/deepeval-4-3-agent-metrics-offline
BibTeX
@online{kelahmet2026deepeval,
author = {Kelahmet, {\"O}zer Cem},
title = {{DeepEval 4.3 agent metrics in depth: tool checks, permission gates, loop detection, G-Eval}},
year = {2026},
month = {nov},
url = {https://www.ozercemkelahmet.com/articles/deepeval-4-3-agent-metrics-offline}
}Version historyfirst version
- Published
Factual corrections are listed here with what changed. Wording and formatting edits are not listed.