Skip to content

Conversation

@steebchen
Copy link
Member

Summary

  • Correctly handle the "tool_calls" finish reason returned by Google in the parseProviderResponse function
  • Add explicit check for "tool_calls" to avoid misclassification as "stop"

Changes

Core Functionality

  • Updated parseProviderResponse in parse-provider-response.ts to:
    • Check if googleFinishReason is "tool_calls" and return "tool_calls" as the finish reason
    • Retain existing handling for "length", "SAFETY" (mapped to "content_filter"), and fallback to "stop" for unknown reasons

Test plan

  • Verify that responses with finish reason "tool_calls" are correctly identified and handled
  • Ensure no regressions in handling other finish reasons
  • Confirm that fallback to "stop" remains intact for unknown reasons

🌿 Generated by Terry


ℹ️ Tag @terragon-labs to ask questions and address PR feedback

📎 Task: https://www.terragonlabs.com/task/0405a65a-261f-45fb-a54d-5774436bfb02

Google AI Studio can return 'tool_calls' directly as a finish reason
when tools are invoked. Previously this was falling through to the
default 'stop' mapping, causing finish reason to show as 'unknown'
in unified responses. Now explicitly handles 'tool_calls' from Google.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 19, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch terragon/fix-google-tool-finish-reason

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot changed the title Fix handling of Google tool finish reason in parseProviderResponse fix(parseProviderResponse): handle Google tool finish reason Sep 19, 2025
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.

2 participants