Skip to content

ai, settings: generalize Gemini 4+ effort and continuation defaults - #886

Merged
rgushchin merged 2 commits into
mainfrom
feat/gemini-effort-and-continuation
Nov 12, 2026
Merged

rgushchin merged 2 commits into
mainfrom
feat/gemini-effort-and-continuation

Conversation

@rgushchin

Copy link
Copy Markdown
Member

Summary

Generalizes Gemini reasoning-effort (thinkingConfig.thinkingLevel) and Long Decodes v2 (maxOutputTokens = 131072) defaults so new Gemini 4+ releases (such as gemini-4-carbon) and custom endpoint aliases work out of the box without per-codename allowlist updates:

  1. Generation-based defaults & explicit --effort handling (ai, settings, reviewer):

    • Replaces the contains("argon") allowlist in model_supports_effort with legacy-generation exclusion (gemini-1*, gemini-2*, gemini-3*, and unversioned 1.x aliases), enabling per-stage EffortMode ("mid" by default) and 131_072 max_tokens automatically across Gemini 4+ releases and custom provider = "gemini" aliases.
    • Honors explicit [review] effort / --effort overrides on any Gemini or Vertex Gemini model instead of silently dropping them, and treats the parent process's resolved --effort flag as authoritative inside stdio-gemini / stdio-claude worker subprocesses.
  2. Runtime 400 fallback for defaulted maxOutputTokens (ai/gemini, ai/vertex):

    • Tracks whether max_tokens was explicitly configured vs. defaulted on GeminiClient and VertexClient.
    • If a defaulted maxOutputTokens triggers a 400 INVALID_ARGUMENT referencing maxOutputTokens / max_output_tokens, records an AtomicBool on the client and retries without maxOutputTokens so the backend uses the model's native output ceiling while keeping cache_identity stable. Explicit max_tokens values continue to fail fast.

Verification

  • make check-pr RANGE=origin/main..HEAD across --all-features, --no-default-features, and --no-default-features --features cache
  • sashiko review --project sashiko --agent origin/main..HEAD (status: clean, 0 findings)

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-bot

sashiko-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

Sashiko review

✓ No issues found across 2 commits.

Full review log on sashiko.sashiko.dev

@rgushchin
rgushchin merged commit d168e75 into main Nov 12, 2026
1 check passed
@rgushchin
rgushchin deleted the feat/gemini-effort-and-continuation branch November 12, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant