Map Gemini LANGUAGE and UNEXPECTED_TOOL_CALL finish reasons - #1100
Merged
Quim Muntal (qmuntal) merged 1 commit intoSep 18, 2026
Merged
Quim Muntal (qmuntal) merged 1 commit into
Quim Muntal (qmuntal) merged 1 commit into
Conversation
toFinishReason dropped two Gemini finish reasons that the Python client maps: LANGUAGE (an unsupported-language content filter) and UNEXPECTED_TOOL_CALL. Both fell through to the default and returned an empty string instead of their canonical framework values. Map LANGUAGE to content_filter and UNEXPECTED_TOOL_CALL to tool_calls, matching Python's _FINISH_REASON_MAP.
PratikDhanave (PratikDhanave)
requested a review
from a team
as a code owner
September 18, 2026 12:18
Copilot started reviewing on behalf of
PratikDhanave (PratikDhanave)
September 18, 2026 12:19
View session
Quim Muntal (qmuntal)
approved these changes
Sep 18, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The mappings and regression tests are covered with no unresolved blocking issues.
Pull request overview
Maps Gemini LANGUAGE and UNEXPECTED_TOOL_CALL finish reasons to canonical framework values.
Changes:
- Maps
LANGUAGEtocontent_filter. - Maps
UNEXPECTED_TOOL_CALLtotool_calls. - Adds regression tests.
File summaries
| File | Description |
|---|---|
provider/geminiprovider/agent.go |
Adds both finish-reason mappings. |
provider/geminiprovider/agent_test.go |
Tests both mappings. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Quim Muntal (qmuntal)
enabled auto-merge
September 18, 2026 12:21
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.
Two Gemini finish reasons were unmapped in
toFinishReasonand fell through to thedefault, returning an emptyFinishReasoninstead of their canonical framework values:LANGUAGE(FinishReasonLanguage) — an unsupported-language content filter — should map tocontent_filter, alongside the other safety/recitation reasons.UNEXPECTED_TOOL_CALL(FinishReasonUnexpectedToolCall) should map totool_calls, alongsideMALFORMED_FUNCTION_CALL.The Python client maps both in
_FINISH_REASON_MAP("LANGUAGE": "content_filter","UNEXPECTED_TOOL_CALL": "tool_calls"). Both constants exist in the pinnedgoogle.golang.org/genaiSDK.Change
genai.FinishReasonLanguageto thecontent_filtercase andgenai.FinishReasonUnexpectedToolCallto thetool_callscase.Test
TestFinishReason_NonStreamingtable withlanguage→content_filterandunexpected_tool_call→tool_calls. Both fail before the change (empty string), pass after.