-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
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-starttool-input-deltatool-calltool-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 0This 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
}
}
} : userProvidedProviderOptionsEnvironment
- Stagehand version: 3.0.7
- Model: google/gemini-3-flash-preview
- Mode:
hybridwithstream: true
References
-
https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai
-
Is there a way to set thinking config for vertex/google gemini? vercel/ai#5460
-
Yes, I can submit a PR
-
Yes, but I need guidance
-
No, I cannot contribute at this time