Skip to content

fix(gemini): trailing empty text part with thoughtSignature#757

Open
HhSen wants to merge 1 commit intocloudwego:mainfrom
HhSen:fix(gemini)/trailing-thoughtSignature
Open

fix(gemini): trailing empty text part with thoughtSignature#757
HhSen wants to merge 1 commit intocloudwego:mainfrom
HhSen:fix(gemini)/trailing-thoughtSignature

Conversation

@HhSen
Copy link
Copy Markdown

@HhSen HhSen commented Apr 1, 2026

What type of PR is this?

fix: there is trailing empty text candidate part with thoughtSignature instead of placing the signature in the first part of functionCall (as described in the document https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures)

Check the PR title.

  • fix(gemini): trailing empty text part with thoughtSignature

(Optional) Translate the PR title into Chinese.

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
fix: there is trailing empty text candidate part with thoughtSignature instead of placing the signature in the first part of functionCall (as described in the document https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures) like:

"candidates": [
            {
                "content": {
                    "parts": [
                        {
                            "functionCall": {
                                ...
                            }
                        },
                        {
                            "text": "",
                            "thoughtSignature": "...thoughtSignature here..."
                        }
                    ],
                    "role": "model"
                },
                "finishReason": "STOP",
                "groundingMetadata": {
                    "retrievalMetadata": {},
                    "searchEntryPoint": {
                        "renderedContent": "..."
                    },
                    "webSearchQueries": [
                        ...
                    ]
                }
            }
        ],

added fallback handle to move the thoughtSignature in the empty part to the first tool_call part

zh(optional):

(Optional) Which issue(s) this PR fixes:

fixed: #756

(optional) The PR that updates user documentation:

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


hehuaisen seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Function call is missing a thought_signature in functionCall parts from Gemini API (model: gemini-3-flash-preview)

2 participants