Package com.tnsai.reasoning.react
Interface StopCondition
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Determines when a ReAct loop should stop.
Stop conditions are evaluated after each step. If any condition returns true, the loop terminates and returns the current best answer.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classMutable context for stop conditions that need to track state across steps. -
Method Summary
Modifier and TypeMethodDescriptionstatic StopConditionanswerContains(String text) Stops when the final answer contains the specified text (case-insensitive).static StopConditionanyOf(StopCondition... conditions) Combines multiple stop conditions with OR logic.static StopConditionStops when the LLM indicates it has a final answer (detects "Final Answer:" pattern).static StopConditionnoActionFor(int consecutiveSteps) Stops when a specific number of consecutive steps have no action.booleanshouldStop(ReActStep step, StopCondition.StopContext context) Evaluates whether the loop should stop.
-
Method Details
-
shouldStop
Evaluates whether the loop should stop.- Parameters:
step- the most recently completed stepcontext- the stop condition context with accumulated state- Returns:
- true if the loop should stop
-
answerContains
Stops when the final answer contains the specified text (case-insensitive). -
finalAnswerDetected
Stops when the LLM indicates it has a final answer (detects "Final Answer:" pattern). -
noActionFor
Stops when a specific number of consecutive steps have no action. -
anyOf
Combines multiple stop conditions with OR logic.
-