Skip to content

RoleViolationMetric strict_mode always succeeds due to threshold initialization #2901

Description

@sahniaditya007

Summary

RoleViolationMetric does not enforce strict mode correctly.

Current Behavior

When strict_mode=True, the threshold is initialized as:

self.threshold = 0 if strict_mode else threshold

The success check later evaluates:

self.success = self.score >= self.threshold

Since the minimum score is 0.0, a failing role violation still satisfies:

0.0 >= 0

making strict mode always succeed.

Expected Behavior

Strict mode should fail whenever any role violation is detected.

Reproduction

  1. Create a RoleViolationMetric with strict_mode=True.
  2. Evaluate a response containing a clear role violation.
  3. Observe that success=True.

Proposed Fix

self.threshold = 1 if strict_mode else threshold

Files

deepeval/metrics/role_violation/role_violation.py

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions