Class ThresholdJudgePolicy<T>

java.lang.Object
com.tnsai.coordination.judge.ThresholdJudgePolicy<T>
Type Parameters:
T - the type of output to evaluate
All Implemented Interfaces:
JudgePolicy

public final class ThresholdJudgePolicy<T> extends Object implements JudgePolicy
A JudgePolicy that approves output when a numeric score meets a threshold.

The caller provides a scoring function that extracts a quality score from the output. If the score meets or exceeds the threshold, the output is approved. Otherwise it is retried (or rejected on the final iteration).

Usage


 JudgePolicy policy = new ThresholdJudgePolicy<>(
     0.8,                          // minimum score
     output -> computeScore(output) // scoring function
 );
 
Since:
0.2.3
  • Constructor Details

    • ThresholdJudgePolicy

      public ThresholdJudgePolicy(double threshold, Class<T> outputType, ToDoubleFunction<T> scoringFunction)
      Creates a threshold policy.
      Parameters:
      threshold - minimum score in [0.0, 1.0] to approve
      outputType - expected output class (for safe casting)
      scoringFunction - extracts a score in [0.0, 1.0] from the output
  • Method Details

    • evaluate

      public JudgeVerdict evaluate(String agentId, Object output, JudgeContext context)
      Description copied from interface: JudgePolicy
      Evaluates an agent's output and produces a verdict.
      Specified by:
      evaluate in interface JudgePolicy
      Parameters:
      agentId - the identifier of the agent whose output is being judged
      output - the output to evaluate (type depends on coordination pattern)
      context - iteration state and history
      Returns:
      a verdict with decision, score, and optional feedback
    • getThreshold

      public double getThreshold()
      Returns the configured threshold.