Repository navigation
fix(gemini): support Gemini 3/3.5 thinking config, thought separation, and reasoning token usage - #418
Open
zchryst wants to merge 1 commit into
Open
fix(gemini): support Gemini 3/3.5 thinking config, thought separation, and reasoning token usage#418zchryst wants to merge 1 commit into
zchryst wants to merge 1 commit into
Conversation
…, and reasoning token usage
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
Fixes three Gemini 3 / 3.5 thinking, context caching, and usage metadata issues in
GeminiProvider(aisuite/providers/gemini_provider.py) andGoogleProvider(aisuite/providers/google_provider.py):ThinkingConfigRouting,cached_contentPassthrough, and Thought Separation:"thinking_config"and"cached_content"toCONFIG_KEYSinaisuite/providers/gemini_provider.py.GeminiProvider._build_thinking_config()to translatereasoning_effort,thinking,thinking_level,thinking_budget, andinclude_thoughtskwargs intogoogle.genai.types.ThinkingConfig, routingthinking_levelfor Gemini 3+ Flash/Pro (with"minimal"on Flash and"low"minimum on Pro) andthinking_budgetfor Gemini 2.5 (with regional prefix normalization such asau.gemini-3.5-flash).GeminiMessageConverter.parse_candidate()andconvert_response()so thought parts (part.thought == True) are separated intoMessage.reasoning_contentinstead of being concatenated intoMessage.content.DEFAULT_TEMPERATUREinaisuite/providers/google_provider.pytoNoneinstead of forcing0.7on Gemini 3+ models.thoughts_token_count/reasoning_tokens):GeminiMessageConverter.get_completion_usage()to extractthoughts_token_countintoCompletionTokensDetails(reasoning_tokens=...)and include(thoughts or 0)in the fallbacktotal_tokenscalculation.Testing
tests/providers/test_gemini_provider.pyandtests/providers/test_google_provider.pycoveringthinking_configandcached_contentrouting across Gemini 3.5 Flash/Pro (including regional prefixes) and Gemini 2.5, thought part separation intoreasoning_content,thoughts_token_countusage details, and default temperature.black --checkand ranpytest(36 passed).