Package com.tnsai.coordination.judge
Class JudgeCoordinator<T>
java.lang.Object
com.tnsai.coordination.judge.JudgeCoordinator<T>
- Type Parameters:
T- the type of output produced by the coordination cycle
Wraps any coordination execution with judge-at-cycle-end quality control.
Implements the Planner-Worker-Judge pattern from Cursor's scaling research:
after each cycle, a JudgePolicy evaluates the output and decides
whether to approve, retry with feedback, or reject.
Graduated Enforcement
- Validate: Judge evaluates output against criteria
- Retry: On RETRY verdict, re-execute with judge feedback (up to maxRetries)
- Stop: On final retry exhaustion, return best result or reject
Usage
JudgeCoordinator<String> coordinator = JudgeCoordinator.<String>builder()
.policy(new ThresholdJudgePolicy<>(0.8, String.class, s -> computeScore(s)))
.maxRetries(3)
.executor((agentId, feedback) -> agent.execute(agentId, feedback))
.build();
JudgeCoordinator.Result<String> result = coordinator.execute("agent-1");
if (result.isApproved()) {
System.out.println("Approved: " + result.output());
}
- Since:
- 0.2.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for JudgeCoordinator.static final recordResult of a judged coordination cycle. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> JudgeCoordinator.Builder<T> builder()Executes the coordination cycle with judge evaluation.
-
Method Details
-
execute
Executes the coordination cycle with judge evaluation.- Parameters:
agentId- the agent to coordinate- Returns:
- the result including output, final verdict, and iteration history
-
builder
-