GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(gemini): add thought signature validation support by QIN2DIM · Pull Request #2120 · langgenius/dify-official-plugins

Conversation

@QIN2DIM

@QIN2DIM QIN2DIM commented Nov 24, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Related Issues or Context

  • fix(gemini): gemini-3-pro-preview function call is missing a thought_signature in functionCall parts. #2088

This commit implements support for thought signature validation in the Gemini LLM model, as required by the new Gemini API features.

  • Added DEFAULT_THOUGHT_SIGNATURE constant with value b'skip_thought_signature_validator'
  • Modified _build_text_parts and build_parts functions to accept is_assistant_tree flag to conditionally apply thought signature
  • Applied thought signature to text parts, file parts, and function call parts when appropriate
  • Updated version to 0.7.0 to reflect new functionality
  • Updated Google GenAI dependency to 1.52.0 to ensure compatibility with new API features
  • Changed provider label from 'Gemini' to 'Gemini dev' to indicate development status
  • Added debug print statement for content inspection during development

This PR contains Changes to Non-Plugin

  • Documentation
  • Other

This PR contains Changes to Non-LLM Models Plugin

  • I have Run Comprehensive Tests Relevant to My Changes

This PR contains Changes to LLM Models Plugin

  • My Changes Affect Message Flow Handling (System Messages and User→Assistant Turn-Taking)
  • My Changes Affect Tool Interaction Flow (Multi-Round Usage and Output Handling, for both Agent App and Agent Node)
  • My Changes Affect Multimodal Input Handling (Images, PDFs, Audio, Video, etc.)
  • My Changes Affect Multimodal Output Generation (Images, Audio, Video, etc.)
  • My Changes Affect Structured Output Format (JSON, XML, etc.)
  • My Changes Affect Token Consumption Metrics
  • My Changes Affect Other LLM Functionalities (Reasoning Process, Grounding, Prompt Caching, etc.)
  • Other Changes (Add New Models, Fix Model Parameters etc.)

Version Control (Any Changes to the Plugin Will Require Bumping the Version)

  • I have Bumped Up the Version in Manifest.yaml (Top-Level Version Field, Not in Meta Section)

Dify Plugin SDK Version

  • I have Ensured dify_plugin>=0.3.0,<0.6.0 is in requirements.txt (SDK docs)

Environment Verification (If Any Code Changes)

Local Deployment Environment

  • Dify Version is: , I have Tested My Changes on Local Deployment Dify with a Clean Environment That Matches the Production Configuration.

SaaS Environment

  • I have Tested My Changes on cloud.dify.ai with a Clean Environment That Matches the Production Configuration

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
QIN2DIM added 3 commits November 24, 2025 14:56
@QIN2DIM
feat(gemini): add thought signature validation support
2711369
This commit implements support for thought signature validation in the Gemini LLM model, as required by the new Gemini API features.

- Added `DEFAULT_THOUGHT_SIGNATURE` constant with value `b'skip_thought_signature_validator'`
- Modified `_build_text_parts` and `build_parts` functions to accept `is_assistant_tree` flag to conditionally apply thought signature
- Applied thought signature to text parts, file parts, and function call parts when appropriate
- Updated version to 0.7.0 to reflect new functionality
- Updated Google GenAI dependency to 1.52.0 to ensure compatibility with new API features
- Changed provider label from 'Gemini' to 'Gemini dev' to indicate development status
- Added debug print statement for content inspection during development
@QIN2DIM
Refactor variable names and update provider label
c61e519
Renamed internal variables from _unsafe_text_part to _unverified_part for clarity and applied conditional assignment of thought_signature. Also removed debug print statements and updated the provider label in google.yaml from 'Gemini dev' to 'Gemini'.
@QIN2DIM
Merge branch 'main' into skip_thought_signature_validator
5aedf6c
@QIN2DIM
QIN2DIM marked this pull request as ready for review November 27, 2025 15:29
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Nov 27, 2025
QIN2DIM
QIN2DIM commented Nov 27, 2025
View reviewed changes

@QIN2DIM QIN2DIM left a comment

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@shimosaka

shimosaka commented Dec 3, 2025

Copy link
Copy Markdown

I'm really looking forward to this PR! I'm encountering the same error when using Nano Banana Pro in my chatflow. Will this PR resolve that issue as well?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

crazywoola
crazywoola approved these changes Dec 3, 2025
View reviewed changes
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Dec 3, 2025
@crazywoola
crazywoola merged commit ca83646 into langgenius:main Dec 3, 2025
@s16173760 s16173760 mentioned this pull request Dec 7, 2025
[BUG]: Gemini 3 Pro function calling fails - missing thoughtSignature support anomalyco/opencode#4832
Closed
@yatotm

yatotm commented Dec 11, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

I tested using the official Agent strategy (https://marketplace.dify.ai/plugins/langgenius/agent) and communicating with the MCP tool via function call, but it still reported an error: Unable to submit request because function call default_api:tavily-searchin the 2. content block is missing athought_signature``.
The Dify version is 1.10.1, running with Docker Compose.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shimosaka

shimosaka commented Dec 11, 2025

Copy link
Copy Markdown

@QIN2DIM
I'm really excited about your previous fix!

I tried testing it with Nono Banana Pro (gemini-2.5-pro-image-preview), but I encountered an error during consecutive image generations (multi-turn conversation).

The first generation works fine. However, the error occurs when sending the previously generated image back as history for the second prompt, because the image part in the history is missing the thought_signature.

Error Message:

PluginInvokeError: {"args":{},"error_type":"ClientError","message":"400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Image part is missing a thought_signature in content position 2, part position 1. Please refer to [https://ai.google.dev/gemini-api/docs/thought-signatures#model-behavior](https://ai.google.dev/gemini-api/docs/thought-signatures#model-behavior) for more details.', 'status': 'INVALID_ARGUMENT'}}"}

I consulted with Gemini, and it suggested that we need to apply the thought_signature to file/image parts as well, not just text parts, when they are part of the assistant's history.

Could you please update the build_parts function inside _format_message_to_gemini_content as shown below?

# Inside build_parts function in _format_message_to_gemini_content

                    if should_upload:
                        uri, mime_type = self._upload_file_content_to_google(
                            obj, genai_client, file_server_url_prefix
                        )
                        _part = types.Part.from_uri(file_uri=uri, mime_type=mime_type)
                        
                        # ▼▼▼ Added: Apply signature to file parts as well ▼▼▼
                        if is_assistant_tree:
                             _part.thought_signature = DEFAULT_THOUGHT_SIGNATURE
                        # ▲▲▲ End of addition ▲▲▲
                        
                        parts_.append(_part)

Best regards

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@QIN2DIM

QIN2DIM commented Dec 11, 2025

Copy link
Copy Markdown
Contributor Author

@laipz8200 🫠

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dosubot dosubot Bot mentioned this pull request Dec 15, 2025
Gemini Nano Banana Pro fails when generating a second image in the same conversation (missing thought_signature) #2262
Closed
6 tasks done
ous50 pushed a commit to ous50/dify-official-plugins that referenced this pull request May 25, 2026
@QIN2DIM @ous50
feat(gemini): add thought signature validation support (langgenius#2120)
0df6937
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@crazywoola crazywoola crazywoola approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@QIN2DIM @shimosaka @yatotm @crazywoola
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.