Issue Classifier
The IssueClassifier in deepeval finds the problems your AI agent caused in a test case, conversation or trace: wrong or made-up information, ignored tool results, failed tool calls, broken output, unanswered requests. It returns every issue it finds, each with the passages that show it, and verifies each one before keeping it.
It is a Classifier with issue-specific prompts and multi-label classification, evidence and review turned on.
Usage
from deepeval.classifiers import IssueClassifier, Label
from deepeval.test_case import LLMTestCase
classifier = IssueClassifier(
name="agent failures",
labels=[
Label(name="Wrong Refund Window", description="States a refund window that differs from the policy."),
Label(name="Ignored Tool Result", description="Contradicts or ignores what a tool returned."),
],
)
test_case = LLMTestCase(
input="What's the refund window?",
actual_output="Refunds close after 7 days.",
retrieval_context=["Refunds are accepted within 30 days of purchase."],
)
classifier.classify(test_case)
for issue in classifier.classifications:
print(issue.label, issue.confidence, "-", issue.reason)Which prints:
Wrong Refund Window 0.93 - The agent said refunds close after 7 days, but the policy allows 30.There are ONE mandatory and ELEVEN optional parameters when creating an IssueClassifier:
name: a string that identifies the classifier.- [Optional]
labels: a list ofLabels or plain strings naming the issues to look for. Required unless alabel_discovery_configis set, in which case it may be left empty. Defaulted to(). - [Optional]
model: a string specifying which of OpenAI's GPT models to use, OR any custom LLM model of typeDeepEvalBaseLLM. Defaulted togpt-5.4. - [Optional]
include_reason: a boolean which when set toTrue, includes a reason for each issue. Defaulted toTrue. - [Optional]
async_mode: a boolean which when set toTrue, enables concurrent execution within theclassify()method. Defaulted toTrue. - [Optional]
classification_template: a subclass ofIssueClassifierTemplateused to override the default prompts. Defaulted toIssueClassifierTemplate. - [Optional]
description: a string saying what the classifier looks for. Defaulted toNone. - [Optional]
max_content_chars: the most characters of content sent to the judge. Defaulted to100000. - [Optional]
evidence_config: anEvidenceConfig. Defaulted toEvidenceConfig(). - [Optional]
review_config: aReviewConfig; itsmin_confidenceis the issue threshold. Defaulted toReviewConfig(). - [Optional]
label_discovery_config: aLabelDiscoveryConfigto find issues you have not named yet. Defaulted toNone. - [Optional]
agent_profile: anAgentProfile. With adescription, behaviour the application was designed to have is not flagged. Defaulted toNone.
Every parameter from description onwards is keyword-only.
An IssueClassifier always returns every issue it finds (multi_label=True), and returns none for a correct, complete response (allow_none=True).
Discovering issues
To find issues you have not named, start with no labels and a LabelDiscoveryConfig:
from deepeval.classifiers import IssueClassifier, LabelDiscoveryConfig
classifier = IssueClassifier(
name="agent failures",
label_discovery_config=LabelDiscoveryConfig(max_new_labels=3),
)Discovered issues are named in 3 to 7 words that say exactly what happened, such as "Quoted Wrong Refund Window", and merged with near-duplicates as described in label discovery. max_new_labels caps how many new issues one test case can add.
How Does It Work?
An IssueClassifier runs the same steps as a Classifier, with two differences:
- Issue guidance: the judge is told to flag only failures on the agent's side, never the user's behaviour, and to return nothing for a correct, complete response.
- Issue review: each issue is re-judged for real harm, and kept only if its confidence is at least
min_confidence.
Issue review
The review reads the content on its own and fills in the agent_behavior it sees, a harm_done passage showing someone got something wrong, broken or not delivered, and any agent_instruction that told the agent to behave that way. It then scores its confidence from those: low when no harm was done or the agent was told to do it. Only the confidence decides:
A dropped issue explains itself in reason, for example: Proposed "Wrong Refund Window" but review dropped it. The agent was told to do this: "Always quote 7 days". The script required it.
Customize Your Template
IssueClassifierTemplate overrides these prompts of ClassifierTemplate and inherits the rest:
guidance(): the paragraph that tells the judge what counts as an issue.label_naming_rule(): how discovered issues are named.review_label(subject: str, label: str, content: str, app_description: str, app_note: str): the issue review, which must keep asking for JSON withagent_behavior,harm_done,agent_instruction,confidenceandreasonfields.review_app_note(): how the review treats behaviour theAgentProfiledescriptionsays was designed.
Subclass IssueClassifierTemplate to change any of them, and pass it as classification_template.