feat: Adding OnModelErrorCallback #750
Open
+912
−164
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: Adding OnModelErrorCallback
This Changelist (CL) introduces new error handling mechanisms for LLM model calls and tool invocations within the Agent Development Kit.
Specifically, it adds:
OnModelErrorCallback: An interface for handling errors that occur during an LLM model call.OnToolErrorCallback: An interface for handling errors during a tool invocation.These callbacks allow for asynchronous or synchronous handling of errors, providing an opportunity to override the error with a custom response or result. The
LlmAgentclass is updated to support these new callbacks, and they are integrated intoBaseLlmFlowandFunctionsto be triggered upon model or tool failures, respectively. Plugin-defined error callbacks are given precedence over agent-defined ones.Additionally, the CL introduces
canonicalmethods (canonicalBeforeAgentCallbacks,canonicalAfterAgentCallbacks, etc.) toBaseAgentandLlmAgentto simplify accessing callback lists, and updates Javadoc for existing callback interfaces. New tests are included to verify the functionality and precedence of the error callbacks.