Repository navigation
Conversation
The picker listed every gemini-* model that supports generateContent, in API order: 37 models today, 18 of them TTS, image generation, Omni, transcription, robotics or computer-use models that aren't meant for chat with function calling. The first thread and "+" without a current thread take the first model of the list, so new threads defaulted to gemini-2.5-flash-preview-tts, which fails the agent's requests. - GeminiProviderImpl hides a model when a specialized family appears as whole parts of its name (tts, image, nano-banana, transcribe, omni, robotics, computer-use, live, audio), so new general models still appear without code changes. - It lists the default first: gemini-3.1-flash-lite (the default before models were fetched from the API), else gemini-flash-lite-latest, else gemini-flash-latest. - "+" keeps the current thread's model only while the picker lists it, so a thread on a model that is no longer offered doesn't pass it on. As before, a Live thread's model is never copied.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@tony-mak The Agent check failed on a flaky unit test that this PR doesn't touch. Could you re-run the failed job? I don't have permission to re-run it.
|
|
Please default to
|
tony-mak
left a comment
There was a problem hiding this comment.
LGTM once the default model comment above is addressed. Feel free to fix and merge.
getAvailableModels no longer moves a default to the front, so the picker shows the models in API order. LlmProvider.defaultModelName names the provider's default (gemini-flash-latest for Gemini), and resolveDefaultModel picks it from the available models, or the first available model when the list doesn't include it. AgentDemoViewModel resolves the default when it loads the models and uses it for the first thread. AgentUiState.Loaded.defaultModel passes it to "+", which uses it when the current thread's model isn't offered.
|
@tony-mak Thanks, done in 0bd2472:
I've updated the description to match. The new commit's workflows are waiting for approval, and I can't merge myself, so this needs a maintainer for both. |
What I have done and why
Problem
Since #60, the Testing Agent's model picker lists every
gemini-*model whosesupportedGenerationMethodsincludegenerateContent, in API order. With my key that is 37 modelstoday, and 18 of them aren't meant for chat with function calling:
gemini-2.5-flash-preview-tts,gemini-3.8-flash-tts, …gemini-3-pro-image,gemini-nano-banana-2.1, …gemini-omni-*gemini-3.5-transcribegemini-robotics-er-2-previewgemini-2.5-computer-use-preview-10-2025The app has had no default model since #60 (before that it was
gemini-3.1-flash-lite). The firstthread and "+" without a current thread take the first model of the list, which today is
gemini-2.5-flash-preview-tts."+" also copies the current thread's model, so once a thread is on that model, every new thread is
too. Every agent request on it failed with
Gemini API error: 500 - {"error":{"message":"An internal error has occurred. …","code":"api_error"}}(2/2 runs).
Solution
GeminiProviderImpl.getAvailableModelsalso hides a model when one of these specialized familiesappears as whole
--separated parts of its name:tts,image,nano-banana,transcribe,omni,robotics,computer-use,live,audio.pro/flash/flash-lite, so newgeneral models keep appearing without code changes, which was Dynamically fetch available LLM models from providers #60's goal. Today's list includes
gemini-4-argon/-carbon/-hydrogen/-neon,gemini-4-cobalt-eapandgemini-3.1-pro-preview-customtools, which a tier allow-list would hide.gemini-flash-latestwhile the models list includes it, otherwise to thefirst available model. The picker keeps API order.
LlmProvider.defaultModelNamenamesit (
gemini-flash-latestfor Gemini), andLlmProvider.resolveDefaultModelpicks it from theavailable models, with that fallback.
AgentDemoViewModelresolves it when the models load and uses it for the first thread.AgentUiState.Loaded.defaultModelpasses it to the "+" button.AgentUiState.Loaded.newThreadModel, whichAgentDemoScreenuses instead of itsinline expression.
maingemini-2.5-flash-preview-ttsgemini-2.5-flash-preview-tts)gemini-flash-latestgemini-flash-latestExisting threads keep the model they were created with. A thread on a now-hidden model still shows
it in the header, and the picker switches it to a listed model.
LLM payload
modelchanges, and only for new threads:"model":"gemini-2.5-flash-preview-tts"becomes"model":"gemini-flash-latest".system_instruction,service_tierandtoolsare the same. I compared the logged request bodiesof both runs, which were taken before the review change, with
gemini-3.1-flash-liteas thedefault.
gemini-flash-latestgets images in functionresults as image parts (Send granted image results to the model #90), where Gemini 1 and 2 models get a text note.
Evidence
Setup: Pixel_9 emulator (API 37), ChatApp from this repo, progressive tool disclosure on.
main: pickermain: "+" copies the TTS modelmain: request failsThe "this PR" screenshots are from 61ac3e9, before the review change. The picker then listed
gemini-3.1-flash-litefirst, and "+" from the TTS thread gavegemini-3.1-flash-lite. Now thepicker keeps API order (
gemini-4-cobalt-eapfirst), and "+" from the TTS thread givesgemini-flash-latest.main, 1/2,main, 2/2,this PR.
gemini-4-cobalt-eap).mainflow: 16-before-flow.mp4.The ChatApp task ("Using ChatApp, get the details for sending Alice Smith the message: See you at 6.
Do not send it yet.") ran end to end on
gemini-flash-lite-latest, which currently servesgemini-3.5-flash-lite:expand_tool_description, thenexpand_function_declarations, thensearchContacts, thenfetchSendMessageDetails, then the answer.On
gemini-3.1-flash-lite, the default before the review change, the same request got503 … "gemini-3.1-flash-lite is currently experiencing high demand"every time I tried between15:16 and 17:02 UTC on 2026-11-23, on both service tiers.
Testing
GeminiProviderImplTest(5 new tests):gemini-flash-latestas the default;gemini-flash-latest, the default is the first available model, even when a hiddenTTS model is listed first;
olive,imagery) doesn't hide a model.LlmProviderTest(new):resolveDefaultModelwhen the default is listed, isn't listed, isn'tnamed, and when there are no models.
AgentUiStateTest(new):newThreadModelfor a listed, unlisted and Live current model, with andwithout loaded models, and without a thread. The default isn't the first available model.
AgentDemoViewModelTest: the first thread andLoaded.newThreadModeluse the provider's default,which isn't the first model.
./gradlew spotlessCheck test validateScreenshotTest -PGEMINI_API_KEY=dummy_key:Targets tested
(before the review change). The unit tests above cover the review change.
Notes
It could only become the default if the models list lacked
gemini-flash-latestand listed thenew family first.
app-side fix.