ReflectAndRetryToolPlugin
Answers a failed tool call with guidance for the model to reflect on the error and retry, allowing up to maxRetries consecutive failures per tool.
A failure is an exception from the tool, a call to an unregistered tool name, or an error that resultErrorExtractor finds in a result; a success resets that tool's count. Mirrors Python ADK's ReflectAndRetryToolPlugin.
InMemoryRunner(agent = agent, plugins = listOf(ReflectAndRetryToolPlugin(maxRetries = 3)))Constructors
Types
Fluent builder for ReflectAndRetryToolPlugin, provided primarily for Java callers. Any property left unset falls back to the same default as the constructor.
Finds an error that a tool reported in its result instead of throwing.
Decides whether the model may retry a failed tool call.
How long ReflectAndRetryToolPlugin keeps counting a tool's consecutive failures.
Properties
The number of consecutive failures of one tool that are answered with retry guidance; the failure after that exceeds the limit. Must not be negative; 0 disables retries.
Finds errors that tools report in their results instead of throwing; when null, no result counts as a failure.
Decides which failures the model may retry. A failure it rejects is not counted and is answered at once with the guidance to stop using the tool, never by throwing; when null, every failure may be retried.
Once the limit is exceeded, whether to stop handling the error or to answer with guidance telling the model to stop using the tool. When set, a thrown error is left to the flow as if the plugin were absent, and an error found in a result is thrown.
Whether a tool's failures are counted per invocation or across them.
Functions
Callback executed after a specific agent finishes its processing.
Callback executed after an LLM response is received.
Callback executed after the ADK runner completes its execution.
Callback executed before a specific agent starts processing.
Callback executed before an LLM request is sent.
Callback executed before the ADK runner starts the main execution loop.
Callback executed before a tool is invoked.
Callback executed when an event is yielded by an agent during execution.
Callback executed when an error occurs during an LLM interaction.
Callback executed when an unhandled error escapes the ADK runner run.
Callback executed when an error occurs during a tool invocation.
Callback executed when a user message is received before an invocation starts.