GeezerVison is showing github.com — feat(gemini): add thought signature validation support by QIN2DIM · Pull Request #2120 · langgenius/dify-official-plugins
Conversation
QIN2DIM
commented
Nov 24, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Related Issues or Context
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
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.
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
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'.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
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?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
yatotm
commented
Dec 11, 2025
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@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
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
ous50
pushed a commit
to ous50/dify-official-plugins
that referenced
this pull request
May 25, 2026
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.
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.
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.
|