Skip to content

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

Open
bennapp wants to merge 1 commit intopatterns-ai-core:mainfrom
bennapp:fix-gemini-response-with-text-and-func
Open

Fix issue where response with text and tool_calls does not return tool calls#1012
bennapp wants to merge 1 commit intopatterns-ai-core:mainfrom
bennapp:fix-gemini-response-with-text-and-func

Conversation

@bennapp
Copy link
Copy Markdown

@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