Repository navigation
fix(platform): keep a flash-suffixed model id on Gemini CLI runs - #3998
Merged
Merged
Conversation
The pinned Gemini CLI (0.49.0) rewrites any --model ending in "flash" to
its own gemini-3.5-flash on API-key auth (config/models.ts resolveModel:
isFlashModel = endsWith('flash'), gated by hasGemini35FlashGAAccess(),
which is unconditionally true for gemini-api-key). A managed
`…/deepseek-flash` therefore reached the gateway as a bare
gemini-3.5-flash and every run died with 400 "could not auto resolve a
provider"; a byo Google gemini-3-flash was silently promoted the same way.
The harness settings now turn on the CLI's dynamic model configuration,
whose resolveModelId returns an id it has no rule for unchanged, so the
CLI requests the id the platform resolved on both lanes. Upstream
narrowed the rewrite to its own aliases in 0.61.0; 0.62.0 also requires
a root-owned system settings file, so the pin bump is separate work.
Gates: the golden exec fixture is re-frozen; exec-builder pins the
fragment and the verbatim --model on both lanes; the runtime image test
drives the pinned CLI through tale-gemini-run against a loopback
gateway stand-in and asserts the request path keeps a flash-suffixed
id, with a control run that still shows the rewrite so a CLI bump that
drops it fails on purpose.
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.
What broke
Every Gemini CLI project-agent run on a model whose id ends in
flashfailed on its first model call —deepseek-flash,glm-5.3-flash,qwen3.6-flash, OpenRoutergoogle/gemini-3.5-flash/deepseek/deepseek-v4-flash, and a byo Googlegemini-3-flashwas silently served asgemini-3.5-flash.Reproduced on the dev stack (task "测试", org
test, Gemini CLI + the org's custom DeepSeek record, modeldeepseek-flash): four runs in 20 s, eachharness_errorwith the CLI's own words,[API Error: {"error":{"code":500,"message":"could not auto resolve a provider for the request, please specify a provider explicitly"}}]. The gateway log shows why:The
--modelthe platform passed only survives in the user agent; the request path carries the CLI's owngemini-3.5-flash, which Bifrost cannot resolve.Root cause
gemini-cli 0.49.0 (the pinned CLI),
packages/core/src/config/models.ts:isFlashModel()includesmodel.endsWith('flash'), anduseGemini3_5Flashcomes fromhasGemini35FlashGAAccess(), which is unconditionallytrueforAuthType.USE_GEMINI— thegemini-api-keyauth type the harness pins on the managed lane. There is no setting for that gate. Upstream narrowed the predicate to an explicit allow-list in 0.61.0 (isPromotableFlashModel: "Keep explicit versioned model IDs intact so callers can pin newer or older Flash models").The fix
resolveModelhas a second path: withexperimental.dynamicModelConfigurationon, it returnsmodelConfigService.resolveModelId(id), which returns an id it has no rule for unchanged, and the flash block is never reached. The gemini harness settings now carry that fragment on both lanes, so the CLI requests the id the platform resolved — a managed gateway ref verbatim, a byo vendor id verbatim.Proven on the dev stack with the pinned 0.49.0 CLI against the real gateway: with the fragment,
…__deepseek__deepseek-flash/deepseek-flashreaches the gateway unchanged, HTTP 200,result: success;deepseek-v4-probehaves as before.Why not bump the pin
0.61.0/0.62.0 fix the rewrite but 0.62.0 also refuses a system settings file unless the file and every ancestor directory are owned by root and not group/other-writable (
packages/core/src/utils/security.ts).tale-gemini-runstages the per-exec settings asagentunder amkdtempin/tmp, so the pin lands on "Invalid auth method selected" (exit 41) before the first call — verified with 0.62.0 installed into a temp prefix inside a session container. Moving the harness to a newer CLI is a separate re-integration; the wrapper's staging contract has to change first.Gates
lib/harnesses/fixtures/exec/gemini.ymlre-frozen (the byte-for-byte golden gate): the 20 stdin payloads gain"experimental":{"dynamicModelConfiguration":true}, nothing else moves.lib/harnesses/exec-builder.test.ts: the gemini exec carries the fragment on both lanes and passes a flash-suffixed--modelverbatim (managed gateway ref and byogemini-3-flash).tests/integration/container-sandbox-runtime-test.ts: the pinned CLI throughtale-gemini-runagainst a loopback stand-in for the gateway (answers 400, so no retry loop; no key, no network) — with the harness settings the request path is/v1beta/models/probe-provider/probe-model-flash; the control run without the fragment still shows the rewrite, so a CLI bump that drops it turns this red on purpose with the message to remove the fragment. Both directions observed in the localtale-sandbox-runtime:latestimage (3.4 s); the whole suite run locally against a fresh image build: 89 passed, 0 failed.tests/manual/reference/automation.mdgets the row.vitest --project server lib/harnesses228/228,tsc --noEmitclean, oxlint/oxfmt clean,lint:manualgreen,lint:conflictsgreen.