Interface StopHook


public interface StopHook
Stop hooks for controlling when the refinement loop should terminate.

Stop hooks provide additional conditions beyond completion criteria for stopping the loop, such as performance thresholds or early exit.

  • Method Summary

    Modifier and Type
    Method
    Description
    static StopHook
    all(StopHook... hooks)
    Combine multiple stop hooks with AND logic.
    static StopHook
    any(StopHook... hooks)
    Combine multiple stop hooks with OR logic.
    static StopHook
    custom(Predicate<com.tnsai.refinement.IterationResult> condition)
    Stop based on custom condition.
    default String
    Gets the name of this stop hook.
    static StopHook
    Stop when all tests pass.
    static StopHook
    Stop when the output compiles successfully.
    static StopHook
    onCostExceeds(int maxTokens)
    Stop if cost (tokens) exceeds budget.
    static StopHook
    onNoImprovement(int consecutiveIterations)
    Stop if no improvement for N iterations.
    static StopHook
    onScoreAbove(double threshold)
    Stop when score exceeds threshold.
    boolean
    shouldStop(com.tnsai.refinement.IterationResult result)
    Evaluates whether the loop should stop.
  • Method Details

    • shouldStop

      boolean shouldStop(com.tnsai.refinement.IterationResult result)
      Evaluates whether the loop should stop.
      Parameters:
      result - The current iteration result
      Returns:
      true if the loop should stop
    • getName

      default String getName()
      Gets the name of this stop hook.
    • onAllTestsPass

      static StopHook onAllTestsPass()
      Stop when all tests pass.
    • onCompileSuccess

      static StopHook onCompileSuccess()
      Stop when the output compiles successfully.
    • onScoreAbove

      static StopHook onScoreAbove(double threshold)
      Stop when score exceeds threshold.
    • onNoImprovement

      static StopHook onNoImprovement(int consecutiveIterations)
      Stop if no improvement for N iterations.
    • onCostExceeds

      static StopHook onCostExceeds(int maxTokens)
      Stop if cost (tokens) exceeds budget.
    • custom

      static StopHook custom(Predicate<com.tnsai.refinement.IterationResult> condition)
      Stop based on custom condition.
    • any

      static StopHook any(StopHook... hooks)
      Combine multiple stop hooks with OR logic.
    • all

      static StopHook all(StopHook... hooks)
      Combine multiple stop hooks with AND logic.