Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Normalize finish_reason to tool_call for Gemini/Vertex AI when tool calls are present#5076

isijoe started this conversation inFeature Requests
Discussion options

Problem

When using Gemini/Vertex AI models with function calling, the API returnsfinish_reason: "stop" even when the response contains tool calls. This is by design from Google – unlike OpenAI and Anthropic, Gemini does not have a dedicatedTOOL_CALL finish reason.

This inconsistency makes it difficult to build provider-agnostic tool execution loops, as the logic typically relies onfinish_reason to determine whether to execute tools and continue the conversation.

Current behavior (Gemini)

{"variant_name":"gemini-2.5-pro","content": [    {"type":"tool_call","id":"0","raw_name":"get_weather","raw_arguments":"{\"location\":\"London\"}"    }  ],"finish_reason":"stop"}

Gemini returns"stop" even with tool calls present.

Expected behavior (OpenAI/Anthropic)

{"content": [...tool_call...],"finish_reason":"tool_call"}

Other providers return"tool_call" or"tool_use".

Proposed solution

Add an option (opt-in or opt-out) to normalizefinish_reason for Gemini responses:

  • Ifcontent contains atool_call block ANDfinish_reason isstop, returnfinish_reason: "tool_call" instead

This would provide consistent behavior across all providers and simplify downstream tool execution logic.

Workaround

Currently, we iterate over thecontent array to detect tool calls and overridefinish_reason manually in our application layer. This works but adds complexity that could be handled at the gateway level.

References

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
1 participant
@isijoe

[8]ページ先頭

©2009-2025 Movatter.jp