ReflectAndRetryToolPlugin class

Plugin that provides reflection guidance and bounded retries for tool errors.

Inheritance

Constructors

ReflectAndRetryToolPlugin({String name = 'reflect_retry_tool_plugin', int maxRetries = 3, bool throwExceptionIfRetryExceeded = true, TrackingScope trackingScope = TrackingScope.invocation})
Creates a reflect-and-retry plugin.

Properties

hashCode int
The hash code for this object.
no setterinherited
maxRetries int
Maximum retry attempts allowed per tool.
final
name String
Unique plugin name used for registration and error reporting.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
throwExceptionIfRetryExceeded bool
Whether to throw when retry limit is exceeded.
final
trackingScope TrackingScope
Scope used for tracking retry counters.
final

Methods

afterAgentCallback({required BaseAgent agent, required CallbackContext callbackContext}) Future<Content?>
Runs after an agent completes.
inherited
afterModelCallback({required CallbackContext callbackContext, required LlmResponse llmResponse}) Future<LlmResponse?>
Runs after a model response is received.
inherited
afterRunCallback({required InvocationContext invocationContext}) Future<void>
Runs after an invocation finishes.
inherited
afterToolCallback({required BaseTool tool, required Map<String, dynamic> toolArgs, required ToolContext toolContext, required Map<String, dynamic> result}) Future<Map<String, dynamic>?>
Intercepts successful tool results and checks for embedded errors.
override
beforeAgentCallback({required BaseAgent agent, required CallbackContext callbackContext}) Future<Content?>
Runs before an agent is invoked.
inherited
beforeModelCallback({required CallbackContext callbackContext, required LlmRequest llmRequest}) Future<LlmResponse?>
Runs before a model request is sent.
inherited
beforeRunCallback({required InvocationContext invocationContext}) Future<Content?>
Runs before an invocation starts.
inherited
beforeToolCallback({required BaseTool tool, required Map<String, dynamic> toolArgs, required ToolContext toolContext}) Future<Map<String, dynamic>?>
Runs before tool execution.
inherited
close() Future<void>
Releases plugin resources.
inherited
extractErrorFromResult({required BaseTool tool, required Map<String, dynamic> toolArgs, required ToolContext toolContext, required Map<String, dynamic> result}) Future<Object?>
Extracts an error object from tool result, if present.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAgentErrorCallback({required BaseAgent agent, required CallbackContext callbackContext, required Object error}) Future<void>
Callback executed when an unhandled exception escapes agent execution.
inherited
onEventCallback({required InvocationContext invocationContext, required Event event}) Future<Event?>
Handles events emitted during invocation.
inherited
onModelErrorCallback({required CallbackContext callbackContext, required LlmRequest llmRequest, required Exception error}) Future<LlmResponse?>
Handles model invocation errors.
inherited
onRunErrorCallback({required InvocationContext invocationContext, required Object error}) Future<void>
Callback executed when an unhandled exception escapes runner execution.
inherited
onToolErrorCallback({required BaseTool tool, required Map<String, dynamic> toolArgs, required ToolContext toolContext, required Exception error}) Future<Map<String, dynamic>?>
Handles tool exceptions and returns retry guidance payloads.
override
onUserMessageCallback({required InvocationContext invocationContext, required Content userMessage}) Future<Content?>
Handles raw user messages before runner processing.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited