Skip to content

Fix issue where response with text and tool_calls does not return tool calls #1012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bennapp
Copy link

@bennapp bennapp commented Jul 1, 2025

tool_calls would return nil for gemini if the response contained parts that had a text response as the first part but then subsequent tool_calls. Now, we fix that by checking if any of the parts of a functionResponse.

This handles a response like this:

{
  "candidates": [
    {
      "content": {
        "parts": [
          {"text": "Let's add those numbers"},
          {
            "functionCall": {
              "name": "calculator__execute",
              "args": {"input": "2+2"}
            }
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP",
      "index": 0,
      "safetyRatings": []
    }
  ]
}

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