Skip to main content

Defect Explainer

AI-generated explanations for defects found during test execution. The service analyzes failed test cases and writes human-readable explanations back into the TestBench execution overview comments.

Endpoint: POST /defect-explanations

Authorization

The triggering user must hold at least one of the following project roles:

RoleDescription
TestManagerFull project management access.
TesterExecution access.

When authenticating with a JWT token, the token must also grant all of the following API token permissions:

PermissionDescription
ReadOwnUserDetailsRead the authenticated user's details.
ReadProjectDetailsRead project metadata.
ReadTovReportRead test-object-version reports.
ReadCycleReportRead test cycle reports.
ReadReportingJobDetailsRead reporting job details.
DownloadReportFileDownload report files.
ReadTestThemeTreeRead the test theme tree.
ReadTestCaseSetDetailsRead test case set details.
ImportExecutionResultsImport execution results (required to write back explanations).
ReadExecutionImportingJobDetailsRead execution import job status.

How it works

  1. The service retrieves all test case sets from the specified test-object-version and cycle (a cycle_key is required).
  2. For each test case set, it applies the following precheck filters. A test case set is included only if all conditions are met:
    • The execution tab is not locked by another user.
    • Execution data exists.
    • The execution verdict is ToVerify.
    • The execution activity status is Performed.
  3. Items that pass the precheck are processed concurrently in the background:
    • Failed test cases are extracted from the execution comments.
    • For each failed test case, the test data and error message are rendered into the prompt template.
    • Each prompt is sent to the configured LLM.
    • All AI-generated explanations are aggregated and written to the comment section of the execution overview.
note

Unlike the other Agents, defect explanations require a cycle_key in the request. If cycle_key is not provided, the precheck fails with a 409 Conflict response.

Configuration

Default configuration

# config.toml
[testbench-ai-service.agents.defect_explainer]
enabled = true
endpoint_path = "/defect-explanations"
class_path = "testbench_ai_service.agents.defect_explainer.agent.DefectExplainer"

[testbench-ai-service.agents.defect_explainer.prompt]
file = "defect_explainer/prompt.yaml"

Agent data

The following variables are generated by the agent and are accessible in prompt templates as {{ agent.<key> }}:

VariableTypeDescription
agent.failed_test_caseStringExecution trace of the failed test case: set name, each step with its execution verdict (►[Pass]/▼[Fail]), and parameters. Children of compound steps are only included when the compound step failed.
agent.error_messageStringThe error message extracted from the failed test case.

User-provided variables

The built-in prompt variants declare the following user-provided variable, accessible as {{ vars.<key> }}:

VariableTypeDescription
vars.validate_outputBooleanWhen enabled, the model first outputs a management summary and then validates that the output contains only the summary. Defaults to disabled.

Project-specific override

# config.toml
[testbench-ai-service.projects."My Project".agents.defect_explainer]
enabled = false

[testbench-ai-service.projects."My Project".agents.defect_explainer.prompt]
variant = "Quick Summary"

Prompt variants

The built-in prompt file (defect_explainer/prompt.yaml) ships with the following variants:

VariantModelDescription
Detailed Explanation (default)gpt-5.5Structured failure analysis with a focused step-by-step examination. Produces a business-readable one-sentence summary. Uses system+user message structure for best results with GPT chat models.
Quick Summarygpt-5.5Fast one-sentence business explanation of the failure based on the highest-level failing step. Cost-efficient; suitable for high-volume runs where speed matters.

Both variants support the optional validate_output user-provided variable. See Prompts for details on how to customize or create your own variants.