fix(gemini): support 'thought_signature' passthrough for multi-turn conversations with Thinking models #20801

Closed
opened 2026-02-21 20:09:02 -05:00 by yindo · 3 comments
Owner

Originally created by @wanghengyu15-glan on GitHub (Dec 4, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.10.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

1.Configure the Gemini provider in Dify using the plugin from the marketplace.

2.Select the model gemini-3-pro-image-preview.

3.Start a conversation and send a message (Turn 1).

    Observation: The model responds correctly, and the raw API response likely contains thought and thought_signature.

3.Send a follow-up message (Turn 2).

4.Error: The request fails or returns an error indicating a context/signature mismatch, as the thought_signature from Turn 1 was not included in the payload for Turn 2.

✔️ Expected Behavior

The Gemini plugin should:

1.Capture the thought and thought_signature fields from the API response when using gemini-3-pro-image-preview.

2.Persist these fields in the conversation history.

3.Pass them back correctly in the contents or history parameter for all subsequent turns to ensure the multi-turn session works as intended.

Actual Behavior

No response

Originally created by @wanghengyu15-glan on GitHub (Dec 4, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.10.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1.Configure the Gemini provider in Dify using the plugin from the marketplace. 2.Select the model gemini-3-pro-image-preview. 3.Start a conversation and send a message (Turn 1). Observation: The model responds correctly, and the raw API response likely contains thought and thought_signature. 3.Send a follow-up message (Turn 2). 4.Error: The request fails or returns an error indicating a context/signature mismatch, as the thought_signature from Turn 1 was not included in the payload for Turn 2. ### ✔️ Expected Behavior The Gemini plugin should: 1.Capture the thought and thought_signature fields from the API response when using gemini-3-pro-image-preview. 2.Persist these fields in the conversation history. 3.Pass them back correctly in the contents or history parameter for all subsequent turns to ensure the multi-turn session works as intended. ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-21 20:09:02 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 4, 2025):

Hi @wanghengyu15-glan! I'm Dosu and I’m helping the dify team.

The Gemini plugin for Dify currently does not persist or pass through the real thought_signature from Gemini API responses in multi-turn conversations. Instead, it uses a fixed placeholder value, which leads to context/signature mismatches and errors with models like gemini-3-pro-image-preview that require the correct thought_signature for each turn. The plugin parses the thought and thought_signature fields from responses but does not store them for reuse, and Dify's core message model does not have a place to keep these fields for subsequent requests. This is why multi-turn context fails with Gemini "Thinking" models in Dify as of v1.10.1 [source].

There is no official fix or workaround yet. The only reliable way to avoid this issue is to use a model that does not require thought_signature, such as qwen-max or DeepSeek, for multi-turn tool calls [source]. If you want to patch this, you would need to modify both the plugin and the core message model to capture, persist, and replay the actual thought_signature from each Gemini response in the conversation history and include it in subsequent requests.

No merged PRs or community fixes currently address this, so a code change is required to fully support Gemini multi-turn conversations with thought_signature passthrough.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 4, 2025): <!-- Greeting --> Hi @wanghengyu15-glan! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> The Gemini plugin for Dify currently does not persist or pass through the real thought_signature from Gemini API responses in multi-turn conversations. Instead, it uses a fixed placeholder value, which leads to context/signature mismatches and errors with models like gemini-3-pro-image-preview that require the correct thought_signature for each turn. The plugin parses the thought and thought_signature fields from responses but does not store them for reuse, and Dify's core message model does not have a place to keep these fields for subsequent requests. This is why multi-turn context fails with Gemini "Thinking" models in Dify as of v1.10.1 [[source](https://github.com/langgenius/dify-official-plugins/blob/e919ce3bfa54960dcffc3029e4e7ee93dbb97257/models/gemini/models/llm/llm.py#L46-L974)]. There is no official fix or workaround yet. The only reliable way to avoid this issue is to use a model that does not require thought_signature, such as qwen-max or DeepSeek, for multi-turn tool calls [[source](https://github.com/langgenius/dify/issues/29075)]. If you want to patch this, you would need to modify both the plugin and the core message model to capture, persist, and replay the actual thought_signature from each Gemini response in the conversation history and include it in subsequent requests. No merged PRs or community fixes currently address this, so a code change is required to fully support Gemini multi-turn conversations with thought_signature passthrough. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/2b30e63c-21be-445c-be83-c5dd97c7a787?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/2b30e63c-21be-445c-be83-c5dd97c7a787?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/2b30e63c-21be-445c-be83-c5dd97c7a787?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/2b30e63c-21be-445c-be83-c5dd97c7a787?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/2b30e63c-21be-445c-be83-c5dd97c7a787?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/2b30e63c-21be-445c-be83-c5dd97c7a787?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/2b30e63c-21be-445c-be83-c5dd97c7a787?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20Gemini%20plugin%20for%20Dify%20currently%20does%20not%20persist%20or%20pass%20through%20the%20real%20thought_signature%20from%20Gemini%20API%20responses%20in%20multi-turn%20conversations.%20Instead%2C%20it%20uses%20a%20fixed%20placeholder%20value%2C%20which%20leads%20to%20context/signature%20mismatches%20and%20errors%20with%20models%20like%20gemini-3-pro-image-preview%20that%20require%20the%20correct%20thought_signature%20for%20each%20turn.%20The%20plugin%20parses%20the%20thought%20and%20thought_signature%20fields%20from%20responses%20but%20does%20not%20store%20them%20for%20reuse%2C%20and%20Dify%27s%20core%20message%20model%20does%20not%20have%20a%20place%20to%20keep%20these%20fields%20for%20subsequent%20requests.%20This%20is%20why%20multi-turn%20context%20fails%20with%20Gemini%20%22Thinking%22%20models%20in%20Dify%20as%20of%20v1.10.1%20%5B%5Bsource%5D%28https%3A//github.com/langgenius/dify-official-plugins/blob/e919ce3bfa54960dcffc3029e4e7ee93dbb97257/models/gemini/models/llm/llm.py%23L46-L974%29%5D.%0A%0AThere%20is%20no%20official%20fix%20or%20workaround%20yet.%20The%20only%20reliable%20way%20to%20avoid%20this%20issue%20is%20to%20use%20a%20model%20that%20does%20not%20require%20thought_signature%2C%20such%20as%20qwen-max%20or%20DeepSeek%2C%20for%20multi-turn%20tool%20calls%20%5B%5Bsource%5D%28https%3A//github.com/langgenius/dify/issues/29075%29%5D.%20If%20you%20want%20to%20patch%20this%2C%20you%20would%20need%20to%20modify%20both%20the%20plugin%20and%20the%20core%20message%20model%20to%20capture%2C%20persist%2C%20and%20replay%20the%20actual%20thought_signature%20from%20each%20Gemini%20response%20in%20the%20conversation%20history%20and%20include%20it%20in%20subsequent%20requests.%20%0A%0ANo%20merged%20PRs%20or%20community%20fixes%20currently%20address%20this%2C%20so%20a%20code%20change%20is%20required%20to%20fully%20support%20Gemini%20multi-turn%20conversations%20with%20thought_signature%20passthrough.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/29152)
Author
Owner

@hjlarry commented on GitHub (Dec 4, 2025):

please try gemini plugin 0.7.0

@hjlarry commented on GitHub (Dec 4, 2025): please try gemini plugin 0.7.0
Author
Owner

@yk133 commented on GitHub (Dec 5, 2025):

@hjlarry Thank you, it's work!

@yk133 commented on GitHub (Dec 5, 2025): @hjlarry Thank you, it's work!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#20801