Gemini Nano Banana Pro fails when generating a second image in the same conversation (missing thought_signature) #876

Closed
opened 2026-02-16 10:20:49 -05:00 by yindo · 2 comments
Owner

Originally created by @MitraSafarinejad on GitHub (Dec 15, 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.9.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When using the Google Gemini nano banana pro to generate images within a single conversation, the first image is generated successfully, but the second image generation fails with a 400 INVALID_ARGUMENT error related to a missing thought_signature.

my gemini plugin version is 0.7.0
I make chatflow and agent and in both i get the same error

Error Message:
Run failed: [google] Error: req_id: b5decf4117 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 for more details.', 'status': 'INVALID_ARGUMENT'}}"}

Image

✔️ Expected Behavior

The model should generate the second image without errors.

Actual Behavior

The second image generation fails with a client-side 400 INVALID_ARGUMENT error.

Originally created by @MitraSafarinejad on GitHub (Dec 15, 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.9.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When using the Google Gemini nano banana pro to generate images within a single conversation, the first image is generated successfully, but the second image generation fails with a 400 INVALID_ARGUMENT error related to a missing thought_signature. my gemini plugin version is 0.7.0 I make chatflow and agent and in both i get the same error Error Message: Run failed: [google] Error: req_id: b5decf4117 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 for more details.', 'status': 'INVALID_ARGUMENT'}}"} <img width="1273" height="1479" alt="Image" src="https://github.com/user-attachments/assets/ae49d237-7264-4310-af78-e5ddc419e3e4" /> ### ✔️ Expected Behavior The model should generate the second image without errors. ### ❌ Actual Behavior The second image generation fails with a client-side 400 INVALID_ARGUMENT error.
yindo added the bug label 2026-02-16 10:20:49 -05:00
yindo closed this issue 2026-02-16 10:20:49 -05:00
Author
Owner

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

The root cause is that the Gemini plugin (v0.7.0) sets a static placeholder for the thought_signature instead of preserving and forwarding the actual signature returned by the Gemini API in previous responses. The Gemini API requires the exact thought_signature from the last response to be included in subsequent requests for multi-turn interactions; using a static value leads to the 400 INVALID_ARGUMENT error you’re seeing when generating a second image in the same conversation. The plugin currently does not capture or reuse the real thought_signature, so a permanent fix would require changes to store and forward the actual signature as described in the Gemini API docs. There are no workarounds documented in the repo or plugin docs. For now, you may be able to avoid the error by starting a new conversation for each image generation, but multi-turn image generation will not work until the plugin is updated to handle thought_signatures correctly.
Reference: Gemini plugin implementation and PR

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 15, 2025): <!-- Answer --> The root cause is that the Gemini plugin (v0.7.0) sets a static placeholder for the thought_signature instead of preserving and forwarding the actual signature returned by the Gemini API in previous responses. The Gemini API requires the exact thought_signature from the last response to be included in subsequent requests for multi-turn interactions; using a static value leads to the 400 INVALID_ARGUMENT error you’re seeing when generating a second image in the same conversation. The plugin currently does not capture or reuse the real thought_signature, so a permanent fix would require changes to store and forward the actual signature as described in the Gemini API docs. There are no workarounds documented in the repo or plugin docs. For now, you may be able to avoid the error by starting a new conversation for each image generation, but multi-turn image generation will not work until the plugin is updated to handle thought_signatures correctly. [Reference: Gemini plugin implementation and PR](https://github.com/langgenius/dify-official-plugins/pull/2120) <!-- 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/37d8af4f-47f2-4a76-a676-037f9b65aa2b?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/37d8af4f-47f2-4a76-a676-037f9b65aa2b?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/37d8af4f-47f2-4a76-a676-037f9b65aa2b?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/37d8af4f-47f2-4a76-a676-037f9b65aa2b?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/37d8af4f-47f2-4a76-a676-037f9b65aa2b?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/37d8af4f-47f2-4a76-a676-037f9b65aa2b?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/37d8af4f-47f2-4a76-a676-037f9b65aa2b?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%20root%20cause%20is%20that%20the%20Gemini%20plugin%20%28v0.7.0%29%20sets%20a%20static%20placeholder%20for%20the%20thought_signature%20instead%20of%20preserving%20and%20forwarding%20the%20actual%20signature%20returned%20by%20the%20Gemini%20API%20in%20previous%20responses.%20The%20Gemini%20API%20requires%20the%20exact%20thought_signature%20from%20the%20last%20response%20to%20be%20included%20in%20subsequent%20requests%20for%20multi-turn%20interactions%3B%20using%20a%20static%20value%20leads%20to%20the%20400%20INVALID_ARGUMENT%20error%20you%E2%80%99re%20seeing%20when%20generating%20a%20second%20image%20in%20the%20same%20conversation.%20The%20plugin%20currently%20does%20not%20capture%20or%20reuse%20the%20real%20thought_signature%2C%20so%20a%20permanent%20fix%20would%20require%20changes%20to%20store%20and%20forward%20the%20actual%20signature%20as%20described%20in%20the%20Gemini%20API%20docs.%20There%20are%20no%20workarounds%20documented%20in%20the%20repo%20or%20plugin%20docs.%20For%20now%2C%20you%20may%20be%20able%20to%20avoid%20the%20error%20by%20starting%20a%20new%20conversation%20for%20each%20image%20generation%2C%20but%20multi-turn%20image%20generation%20will%20not%20work%20until%20the%20plugin%20is%20updated%20to%20handle%20thought_signatures%20correctly.%20%20%0A%5BReference%3A%20Gemini%20plugin%20implementation%20and%20PR%5D%28https%3A//github.com/langgenius/dify-official-plugins/pull/2120%29)&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/29691)
Author
Owner

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

This error happens because the Gemini plugin does not capture and replay the required thought_signature token from the Gemini API response when making a second image generation request in the same conversation. The Gemini API expects the thought_signature from the previous response to be included in subsequent requests to maintain context, especially for multi-turn tool calls and image generation. Without this, you get a 400 INVALID_ARGUMENT error about a missing thought_signature. This is a known limitation in the current plugin implementation—there is no code path that preserves and reuses the real thought_signature; instead, a hard-coded placeholder is used, which only works for the first turn and fails on the second and beyond [source 1] [source 2].

There is no official fix or merged pull request for this yet. Some maintainers have mentioned possible bypass methods, but nothing is documented or released. The only workaround is to use a different model (like qwen-max), but this is not a solution if you need Gemini-specific features [source 3].

If you need this fixed, you’ll need to monitor for plugin updates or consider contributing a patch that properly captures and replays the thought_signature as described in the Gemini API docs.

To reply, just mention @dosu.


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

Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 15, 2025): <!-- Answer --> This error happens because the Gemini plugin does not capture and replay the required `thought_signature` token from the Gemini API response when making a second image generation request in the same conversation. The Gemini API expects the `thought_signature` from the previous response to be included in subsequent requests to maintain context, especially for multi-turn tool calls and image generation. Without this, you get a 400 INVALID_ARGUMENT error about a missing thought_signature. This is a known limitation in the current plugin implementation—there is no code path that preserves and reuses the real thought_signature; instead, a hard-coded placeholder is used, which only works for the first turn and fails on the second and beyond [[source 1]](https://github.com/langgenius/dify-official-plugins/issues/2168) [[source 2]](https://github.com/langgenius/dify-official-plugins/blob/c426921b2fc9a84857741790431e5b9113723ae2/models/gemini/models/llm/llm.py#L53-L975). There is no official fix or merged pull request for this yet. Some maintainers have mentioned possible bypass methods, but nothing is documented or released. The only workaround is to use a different model (like qwen-max), but this is not a solution if you need Gemini-specific features [[source 3]](https://github.com/langgenius/dify-official-plugins/issues/2168). If you need this fixed, you’ll need to monitor for plugin updates or consider contributing a patch that properly captures and replays the thought_signature as described in the Gemini API docs. <!-- 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/b0761fc6-ab57-402c-a16f-3ebabcebbe3a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/b0761fc6-ab57-402c-a16f-3ebabcebbe3a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/b0761fc6-ab57-402c-a16f-3ebabcebbe3a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/b0761fc6-ab57-402c-a16f-3ebabcebbe3a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/b0761fc6-ab57-402c-a16f-3ebabcebbe3a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/b0761fc6-ab57-402c-a16f-3ebabcebbe3a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/b0761fc6-ab57-402c-a16f-3ebabcebbe3a?feedback_type=other)</sup> [![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20error%20happens%20because%20the%20Gemini%20plugin%20does%20not%20capture%20and%20replay%20the%20required%20%60thought_signature%60%20token%20from%20the%20Gemini%20API%20response%20when%20making%20a%20second%20image%20generation%20request%20in%20the%20same%20conversation.%20The%20Gemini%20API%20expects%20the%20%60thought_signature%60%20from%20the%20previous%20response%20to%20be%20included%20in%20subsequent%20requests%20to%20maintain%20context%2C%20especially%20for%20multi-turn%20tool%20calls%20and%20image%20generation.%20Without%20this%2C%20you%20get%20a%20400%20INVALID_ARGUMENT%20error%20about%20a%20missing%20thought_signature.%20This%20is%20a%20known%20limitation%20in%20the%20current%20plugin%20implementation%E2%80%94there%20is%20no%20code%20path%20that%20preserves%20and%20reuses%20the%20real%20thought_signature%3B%20instead%2C%20a%20hard-coded%20placeholder%20is%20used%2C%20which%20only%20works%20for%20the%20first%20turn%20and%20fails%20on%20the%20second%20and%20beyond%20%5B%5Bsource%201%5D%5D%28https%3A//github.com/langgenius/dify-official-plugins/issues/2168%29%20%5B%5Bsource%202%5D%5D%28https%3A//github.com/langgenius/dify-official-plugins/blob/c426921b2fc9a84857741790431e5b9113723ae2/models/gemini/models/llm/llm.py%23L53-L975%29.%0A%0AThere%20is%20no%20official%20fix%20or%20merged%20pull%20request%20for%20this%20yet.%20Some%20maintainers%20have%20mentioned%20possible%20bypass%20methods%2C%20but%20nothing%20is%20documented%20or%20released.%20The%20only%20workaround%20is%20to%20use%20a%20different%20model%20%28like%20qwen-max%29%2C%20but%20this%20is%20not%20a%20solution%20if%20you%20need%20Gemini-specific%20features%20%5B%5Bsource%203%5D%5D%28https%3A//github.com/langgenius/dify-official-plugins/issues/2168%29.%0A%0AIf%20you%20need%20this%20fixed%2C%20you%E2%80%99ll%20need%20to%20monitor%20for%20plugin%20updates%20or%20consider%20contributing%20a%20patch%20that%20properly%20captures%20and%20replays%20the%20thought_signature%20as%20described%20in%20the%20Gemini%20API%20docs.)&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-official-plugins/issues/2262)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#876