Invoke FirebaseProvider's onFunctionCalls callback - #199
Open
shoemoney wants to merge 1 commit into
Open
Conversation
The onFunctionCalls constructor parameter added in flutter#99 was accepted but never stored or invoked after GeminiProvider and VertexProvider were consolidated into FirebaseProvider. Store the callback and invoke it once per turn with the function calls collected from that turn, and add a regression test that drives a stubbed streaming response through the provider.
yjbanov
reviewed
Aug 27, 2026
| GenerationConfig? chatGenerationConfig, | ||
| Future<Map<String, Object?>?> Function(FunctionCall)? onFunctionCall, | ||
| }) : _model = model, | ||
| _onFunctionCalls = onFunctionCalls, |
There was a problem hiding this comment.
While we're at it, should we also rename the callback to willCallFunctions? I'm not a fan of the on prefix, as it doesn't explain when exactly the callback is called relative to the anchor event. Otherwise, the bug fix looks good.
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.
FirebaseProvider's constructor accepts anonFunctionCallsparameter but never stores or invokes it, so the callback silently never fires. The parameter arrived in #99, which wired it into the formerGeminiProviderandVertexProvider; when those were consolidated intoFirebaseProvider, the parameter survived but the wiring did not.This change stores the callback and invokes it once per turn with the function calls collected from that turn, matching the #99 behavior. It adds a regression test that drives a stubbed streaming response (a function-call turn followed by a text turn) through the provider via firebase_ai's
createModelWithClienttest hook, asserting the callback fires with the collected calls and stays silent on text-only turns. Two dev dependencies (firebase_core,firebase_core_platform_interface) were added for the Firebase core test mocks.flutter test(8 tests),dart analyze --fatal-infos,dart format,dart fix --dry-run, anddart doc --dry-runall pass.