Skip to content

No way to distinguish thought file from regular file in Gemini 3 image responses #11461

@rasmi

Description

@rasmi

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

  1. Use generateText with a gemini-3-pro-image-preview
  2. Enable thinking with providerOptions.google.thinkingConfig.includeThoughts: true
  3. Request image generation that triggers thinking (the model generates intermediate images during thinking)
  4. 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: truetype: "reasoning"
  • File with thought: truetype: "file" with no marker (thinking file, but not distinguished)
  • File with thoughtSignaturetype: "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

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

ai/corecore functions like generateText, streamText, etc. Provider utils, and provider spec.ai/providerrelated to a provider package. Must be assigned together with at least one `provider/*` labelprovider/communitysupport

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions