Repository navigation
Fix callbacks for synchronous model errors - #1649
codingkiddo wants to merge 1 commit into
Conversation
|
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>
7eab695 to
697dfbe
Compare
Hi @hemasekhar-p - Thanks for the review. I’ve squashed the changes into a single signed-off commit (697dfbe) and updated the PR. |
|
@codingkiddo, Thank you for the quick update. Our team is currently reviewing your changes and we will reach out if we need any further information. |
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.