Class JudgeCoordinator<T>

java.lang.Object
com.tnsai.coordination.judge.JudgeCoordinator<T>
Type Parameters:
T - the type of output produced by the coordination cycle

public final class JudgeCoordinator<T> extends Object
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

  1. Validate: Judge evaluates output against criteria
  2. Retry: On RETRY verdict, re-execute with judge feedback (up to maxRetries)
  3. 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
  • Method Details

    • execute

      public JudgeCoordinator.Result<T> execute(String agentId)
      Executes the coordination cycle with judge evaluation.
      Parameters:
      agentId - the agent to coordinate
      Returns:
      the result including output, final verdict, and iteration history
    • builder

      public static <T> JudgeCoordinator.Builder<T> builder()