Class FailureTracker
java.lang.Object
uno.anahata.ai.tools.FailureTracker
Tracks consecutive failures of tool calls and implements a temporary
blocking mechanism.
If a specific tool (identified by its name and arguments) fails repeatedly within a short time window, this tracker will block subsequent calls to that tool to prevent infinite loops or excessive resource consumption.
-
Constructor Summary
ConstructorsConstructorDescriptionFailureTracker(Chat chat) Constructs a new FailureTracker for the given Chat instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanisBlocked(com.google.genai.types.FunctionCall functionCall) Checks if a specific function call is currently blocked due to repeated failures.voidrecordFailure(com.google.genai.types.FunctionCall functionCall, Exception e) Records a failure for a specific function call.
-
Constructor Details
-
FailureTracker
Constructs a new FailureTracker for the given Chat instance.- Parameters:
chat- The Chat instance.
-
-
Method Details
-
recordFailure
Records a failure for a specific function call.- Parameters:
functionCall- The function call that failed.e- The exception that occurred.
-
isBlocked
public boolean isBlocked(com.google.genai.types.FunctionCall functionCall) Checks if a specific function call is currently blocked due to repeated failures.This method also performs cleanup of expired failure records based on the configured time window.
- Parameters:
functionCall- The function call to check.- Returns:
trueif the call is blocked,falseotherwise.
-
