Skip to content

[Bug] Gemini model does not handle multiple text parts #3229

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
nilnor opened this issue May 17, 2025 · 2 comments
Open

[Bug] Gemini model does not handle multiple text parts #3229

nilnor opened this issue May 17, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@nilnor
Copy link

nilnor commented May 17, 2025

Description

The Gemini's parse_provider_response method does not handle multiple text parts. Now, I do not know why on earth the genapi/API returns multiple parts only containing "text" to begin with, but it does..

Example of a response as seen from HTTP logs:

"candidates": [
  {
    "content": {
      "parts": [
        {
          "text": "Well here's one line\n"
        },
        {
          "text": "and another..\n"
        },
        {
          "text": "and it goes on.. :("
        }
      ]
    }
  }
]     

The current implementation goes through each part and assigns a part with "text" as the content, actually only assigning the last part as the message. As said I don't know why the response would be like this, but the current assumption of there being only one text part is clearly wrong.

Steps to Reproduce

Get the model to generate a response like this and check the incoming data.

Agent Configuration (if applicable)

No response

Expected Behavior

Text parts should be concatenated and returned as the response's content.

Actual Behavior

Only the last part is reported as the response's content.

Screenshots or Logs (if applicable)

No response

Environment

Anything capable of using the library

Possible Solutions (optional)

See above.

Additional Context

No response

@nilnor nilnor added the bug Something isn't working label May 17, 2025
Copy link

linear bot commented May 17, 2025

@nilnor
Copy link
Author

nilnor commented May 17, 2025

Some additional info: This is with Gemini 2.5 pro (gemini-2.5-pro-preview-05-06). AI being what it is it now happens only irregularly.. Still, handling this case in the code would account for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant