Description
gemini-3-pro-image-preview: thought: true not translated for file parts (inconsistent with text parts)
Description
When using Gemini 3 thinking models (e.g., gemini-3-pro-image-preview) with includeThoughts: true, the AI SDK correctly translates text parts marked with thought: true to type: "reasoning" in the unified message format. However, file parts (images) marked with thought: true are not translated - they appear as regular type: "file" with no indication they are thought-generated.
This inconsistency makes it difficult to filter thought-generated images from output images in a provider-agnostic way.
Steps to Reproduce
- Use
generateText with a gemini-3-pro-image-preview
- Enable thinking with
providerOptions.google.thinkingConfig.includeThoughts: true
- Request image generation that triggers thinking (the model generates intermediate images during thinking)
- Inspect
response.messages
Raw Gemini Response
Gemini correctly marks all thought content with thought: true:
{
"candidates": [{
"content": {
"parts": [
{ "text": "Thinking about the image...", "thought": true },
{ "inlineData": { "mimeType": "image/jpeg", "data": "..." }, "thought": true },
{ "text": "Here is your image:", "thought": false },
{ "inlineData": { "mimeType": "image/jpeg", "data": "..." }, "thoughtSignature": "..." }
]
}
}]
}
AI SDK Unified Format (response.messages)
[{
"role": "assistant",
"content": [
{ "type": "reasoning", "text": "Thinking about the image..." },
{ "type": "file", "mediaType": "image/jpeg", "data": "..." },
{ "type": "text", "text": "Here is your image:" },
{ "type": "file", "mediaType": "image/jpeg", "data": "...", "providerOptions": { "google": { "thoughtSignature": "..." } } }
]
}]
Expected Behavior
Thought-generated files should be distinguishable from output files in the unified format.
Actual Behavior
- Text with
thought: true → type: "reasoning"
- File with
thought: true → type: "file" with no marker (thinking file, but not distinguished)
- File with
thoughtSignature → type: "file" with providerOptions.google.thoughtSignature (i.e. output file, not thinking file)
Current Workaround
Detect thinking responses by checking if ANY file has providerOptions, then only include files that have providerOptions (output files have it, thought files don't):
const isThinkingResponse = content.some(
(part) => part.type === 'file' && !!part.providerOptions
);
for (const part of content) {
if (part.type === 'file') {
const shouldInclude = isThinkingResponse ? !!part.providerOptions : true;
if (shouldInclude) {
// This is an output file, not a thought-generated file
}
}
}
AI SDK Version
Environment
| Package |
Installed |
| ai |
6.0.3 |
| @ai-sdk/openai |
3.0.1 |
| @ai-sdk/google |
3.0.1 |
| ollama-ai-provider-v2 |
2.0.0 |
Code of Conduct
Description
gemini-3-pro-image-preview:thought: truenot translated for file parts (inconsistent with text parts)Description
When using Gemini 3 thinking models (e.g.,
gemini-3-pro-image-preview) withincludeThoughts: true, the AI SDK correctly translates text parts marked withthought: truetotype: "reasoning"in the unified message format. However, file parts (images) marked withthought: trueare not translated - they appear as regulartype: "file"with no indication they are thought-generated.This inconsistency makes it difficult to filter thought-generated images from output images in a provider-agnostic way.
Steps to Reproduce
generateTextwith agemini-3-pro-image-previewproviderOptions.google.thinkingConfig.includeThoughts: trueresponse.messagesRaw Gemini Response
Gemini correctly marks all thought content with
thought: true:{ "candidates": [{ "content": { "parts": [ { "text": "Thinking about the image...", "thought": true }, { "inlineData": { "mimeType": "image/jpeg", "data": "..." }, "thought": true }, { "text": "Here is your image:", "thought": false }, { "inlineData": { "mimeType": "image/jpeg", "data": "..." }, "thoughtSignature": "..." } ] } }] }AI SDK Unified Format (response.messages)
[{ "role": "assistant", "content": [ { "type": "reasoning", "text": "Thinking about the image..." }, { "type": "file", "mediaType": "image/jpeg", "data": "..." }, { "type": "text", "text": "Here is your image:" }, { "type": "file", "mediaType": "image/jpeg", "data": "...", "providerOptions": { "google": { "thoughtSignature": "..." } } } ] }]Expected Behavior
Thought-generated files should be distinguishable from output files in the unified format.
Actual Behavior
thought: true→type: "reasoning"thought: true→type: "file"with no marker (thinking file, but not distinguished)thoughtSignature→type: "file"withproviderOptions.google.thoughtSignature(i.e. output file, not thinking file)Current Workaround
Detect thinking responses by checking if ANY file has
providerOptions, then only include files that haveproviderOptions(output files have it, thought files don't):AI SDK Version
Environment
Code of Conduct