Repository navigation
ai, settings: generalize Gemini 4+ effort and continuation defaults - #886
Merged
Merged
Conversation
Currently model_supports_effort checks whether the model string contains argon, gating both per-stage reasoning effort (thinkingLevel) and the 131072 maxOutputTokens default for Long Decodes v2 continuation. As a result, newer Gemini 4+ releases such as gemini-4-carbon (as well as custom endpoint aliases) silently drop configured effort flags and omit the 128k continuation token budget until each new codename is added by hand. Invert the heuristic from a codename allowlist to legacy-generation exclusion: treat any Gemini model except pre-Gemini-4 releases (gemini-1*, gemini-2*, gemini-3*, and unversioned legacy 1.x aliases) as supporting per-stage effort and Long Decodes v2 continuation by default, including bare model aliases when provider is set to gemini. Always honor an explicit review.effort or --effort override on Gemini and Vertex Gemini models, and treat the parent process --effort flag as authoritative across stdio-gemini and stdio-claude worker subprocesses. Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Even with generation-based defaults, a new or custom Gemini model alias may have an output ceiling below the 131072 Long Decodes v2 budget and reject generationConfig.maxOutputTokens with HTTP 400 INVALID_ARGUMENT. Track whether max_tokens was explicitly configured versus defaulted on GeminiClient and VertexClient. When a defaulted maxOutputTokens triggers a 400 rejection referencing maxOutputTokens or max_output_tokens, record an AtomicBool on the client and retry once with maxOutputTokens omitted so the backend uses the model native ceiling on that call and all subsequent calls without altering cache_identity. Explicit max_tokens values continue to fail fast when rejected. Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Sashiko review✓ No issues found across 2 commits. |
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.
Summary
Generalizes Gemini reasoning-effort (
thinkingConfig.thinkingLevel) and Long Decodes v2 (maxOutputTokens = 131072) defaults so new Gemini 4+ releases (such asgemini-4-carbon) and custom endpoint aliases work out of the box without per-codename allowlist updates:Generation-based defaults & explicit
--efforthandling (ai,settings,reviewer):contains("argon")allowlist inmodel_supports_effortwith legacy-generation exclusion (gemini-1*,gemini-2*,gemini-3*, and unversioned 1.x aliases), enabling per-stageEffortMode("mid"by default) and131_072max_tokensautomatically across Gemini 4+ releases and customprovider = "gemini"aliases.[review] effort/--effortoverrides on any Gemini or Vertex Gemini model instead of silently dropping them, and treats the parent process's resolved--effortflag as authoritative insidestdio-gemini/stdio-claudeworker subprocesses.Runtime 400 fallback for defaulted
maxOutputTokens(ai/gemini,ai/vertex):max_tokenswas explicitly configured vs. defaulted onGeminiClientandVertexClient.maxOutputTokenstriggers a400 INVALID_ARGUMENTreferencingmaxOutputTokens/max_output_tokens, records anAtomicBoolon the client and retries withoutmaxOutputTokensso the backend uses the model's native output ceiling while keepingcache_identitystable. Explicitmax_tokensvalues continue to fail fast.Verification
make check-pr RANGE=origin/main..HEADacross--all-features,--no-default-features, and--no-default-features --features cachesashiko review --project sashiko --agent origin/main..HEAD(status: clean, 0 findings)