ToolMisuseBreaker class final
Threshold semantics: noteThreshold consecutive identical failures arm the corrective note for the NEXT request; stopThreshold stop executing that identical call in the current run (the loop refuses it before any execution, with an honest error naming the misuse).
Constructors
- ToolMisuseBreaker({int noteThreshold = 3, int stopThreshold = 6, int descriptionLimit = 240})
Properties
- descriptionLimit → int
-
Cap on the tool-description excerpt carried by the corrective note.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- noteThreshold → int
-
Consecutive identical failures before the corrective note arms.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stopThreshold → int
-
Consecutive identical failures before the identical call is refused
for the rest of the run.
final
Methods
-
argsKey(
Map< String, dynamic> arguments) → String - Canonical key for a tool call's arguments: the identical retry has a byte-identical argument map (same JSON source, same insertion order).
-
beginRun(
) → void - Wipes all counters, notes, and stopped keys (loop run start).
-
drainPendingNote(
) → String? - Drains armed corrective notes (joined) for injection into the next request payload; null when none armed. Request-only: the transcript never sees the note.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
observeFailure(
String toolName, Map< String, dynamic> arguments, String errorText, {String? toolDescription}) → bool -
Records one failed execution of
toolName. Returns true when this failure just armed a corrective note for the next request (the loop drains it via drainPendingNote). -
observeSuccess(
String toolName) → void - Records a successful execution: the model recovered, so this tool's consecutive-failure state clears.
-
refusalFor(
String toolName, Map< String, dynamic> arguments) → String? - Whether the loop must refuse this call without executing it: the identical call has hit stopThreshold consecutive failures in this run. The returned text is the honest, remedy-bearing refusal.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited