Skip to content

Feature Request: Expose Gemini 3 thinking/reasoning via includeThoughts in providerOptions #1524

@hoverlover

Description

@hoverlover

Summary

When using Gemini 3 models with stream: true, reasoning/thinking output is never available in the onChunk callback or reasoningText field. This is because Stagehand hardcodes providerOptions for Gemini 3 and doesn't include thinkingConfig: { includeThoughts: true }.

Current Behavior

With stream: true and a Gemini 3 model, the onChunk callback only receives tool-related chunks:

  • tool-input-start
  • tool-input-delta
  • tool-call
  • tool-result

No text-delta or reasoning-delta chunks are ever emitted. In onStepFinish, reasoning is always an empty array and reasoningText is always undefined.

Expected Behavior

Gemini 3's thinking/reasoning should be accessible via streaming when enabled. According to Google's documentation, this requires setting includeThoughts: true in the thinking config.

Root Cause

In dist/index.js, Stagehand hardcodes providerOptions for Gemini 3 models:

providerOptions: wrappedModel.modelId.includes("gemini-3") ? {
  google: {
    mediaResolution: "MEDIA_RESOLUTION_HIGH"
  }
} : void 0

This appears in two places (for streaming and non-streaming execution). The thinkingConfig with includeThoughts: true is not included.

Proposed Solution

Allow users to pass custom providerOptions through AgentModelConfig, or add thinkingConfig support:

Option A: Extend AgentModelConfig

  const agent = stagehand.agent({
    model: {
      modelName: "google/gemini-3-flash-preview",
      providerOptions: {
        google: {
          thinkingConfig: {
            includeThoughts: true,
            thinkingLevel: "medium"
          }
        }
      }
    },
    stream: true,
    mode: "hybrid",
  });

Option B: Add dedicated thinking config

  const agent = stagehand.agent({
    model: { modelName: "google/gemini-3-flash-preview" },
    stream: true,
    thinking: {
      includeThoughts: true,
      thinkingLevel: "medium"  // or thinkingBudget for Gemini 2.5
    }
  });

Option C: Merge user-provided providerOptions with defaults

Update the hardcoded providerOptions to merge with any user-provided options from AgentModelConfig:

  providerOptions: wrappedModel.modelId.includes("gemini-3") ? {
    google: {
      mediaResolution: "MEDIA_RESOLUTION_HIGH",
      ...userProvidedGoogleOptions,  // from AgentModelConfig
      thinkingConfig: {
        ...userProvidedThinkingConfig
      }
    }
  } : userProvidedProviderOptions

Environment

  • Stagehand version: 3.0.7
  • Model: google/gemini-3-flash-preview
  • Mode: hybrid with stream: true

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions