Repository navigation
Fix callbacks for synchronous model errors - #1649
Open
codingkiddo wants to merge 1 commit into
Open
codingkiddo wants to merge 1 commit into
codingkiddo wants to merge 1 commit into
Conversation
Contributor
|
Hi @codingkiddo, thank you for your contribution! We appreciate you taking the time to submit this pull request. As per contribution policy, your PR consists of a single commit. To proceed with review, Could you please change your commits accordingly? |
Signed-off-by: Vinod Kumar <codingkiddo@gmail.com>
codingkiddo
force-pushed
the
fix/synchronous-model-error-callbacks
branch
from
October 13, 2026 09:21
7eab695 to
697dfbe
Compare
Author
Hi @hemasekhar-p - Thanks for the review. I’ve squashed the changes into a single signed-off commit (697dfbe) and updated the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of Change
Problem:
BaseLlmFlowinvokesgenerateContent()before attaching its model-errorhandler. If a model throws synchronously before returning a
Flowable,the exception bypasses
onModelErrorCallbackand downstream errorspan recording.
The existing outer
Flowable.deferemits the exception outside theinner error-handling chain.
Solution:
Wrap
generateContent()inFlowable.deferso synchronous exceptionsreach the existing model-error handling.
Callbacks can provide a fallback response. If no fallback is provided,
the original exception propagates through the existing error-recording
path. The fix applies across model implementations.
Testing Plan
Unit Tests:
Added regression tests covering:
when the callback returns empty.
Validation command:
Result: 2 tests run, 0 failures, 0 errors, 0 skipped.
Manual End-to-End (E2E) Tests:
Ran a standalone Maven application using
LlmAgent,InMemoryRunner,and a custom Ollama-backed
BaseLlmadapter against local Ollama.Requested a nonexistent model to trigger HTTP 404. The adapter performs
the HTTP request eagerly and throws synchronously before returning
its
Flowable.With the fixed SDK,
onModelErrorCallbackreceived the exception exactlyonce, and the caller received the callback's fallback response.
Command:
mvn compile exec:java -Dexec.args="adk-error-demo-missing-model"Observed output:
A separate SDK run using a simulated synchronous model failure reproduced
the original behavior: the exception escaped and the callback count was zero.
Checklist
Additional context
The regression tests require no external API credentials or Ollama server.
The manual demonstration uses a custom eager Ollama adapter to exercise
synchronous model failures; it does not establish a defect in a built-in
Ollama integration.
No dependent module changes are required.