https://github.com/flutter/genui/tree/main/packages/genui_firebase_ai and https://github.com/flutter/genui/tree/main/packages/genui_google_generative_ai have a lot of similar logic, e.g. the tool loop.
Ideally, they would be structured like:
genui: contains some LocalAgent utility which implements generic agent loop etc in Dart
genui_google_generative_ai implements a thing that can make an inference via the REST API, do conversion of types etc.
genui_firebase_ai the same for Firebase AI Logic
Deduplicating this code will allow us to put more effort into the local agent pattern which could be helpful for some customers, because we will centralize this logic. For example, what if we want to abandon tool calling and use regular unstructured output instead, with error correction etc?