Package com.tnsai.coordination.judge
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
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 Summary
ConstructorsConstructorDescriptionThresholdJudgePolicy(double threshold, Class<T> outputType, ToDoubleFunction<T> scoringFunction) Creates a threshold policy. -
Method Summary
Modifier and TypeMethodDescriptionevaluate(String agentId, Object output, JudgeContext context) Evaluates an agent's output and produces a verdict.doubleReturns the configured threshold.
-
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 approveoutputType- expected output class (for safe casting)scoringFunction- extracts a score in [0.0, 1.0] from the output
-
-
Method Details
-
evaluate
Description copied from interface:JudgePolicyEvaluates an agent's output and produces a verdict.- Specified by:
evaluatein interfaceJudgePolicy- Parameters:
agentId- the identifier of the agent whose output is being judgedoutput- 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.
-