Correctly output thinking for Gemini Text adapter #210
main fromrefs/pull/210/head·merged by AlemTuzlak View on GitHub🎯 Changes#
Fix that a part that has the thought flag set is output as thinking chunk instead of content. Fixes: https://github.com/TanStack/ai/issues/209
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm run test:pr.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Summary by CodeRabbit#
Bug Fixes
- Gemini Text streaming now separates "thinking" chunks from assistant content and avoids spurious thinking updates.
New Features
- Advanced thinking options exposed (thinking level and optional budget) for Gemini models.
- Provider config surface simplified for easier option use.
Examples / UI
- Default Gemini model in the chat example updated to "Gemini 2.5 - Flash".
- Example chat demonstrates enabling thinking output with a thinking budget.
Chores
- Changesets added to mark patch releases.
- 1
View your CI Pipeline Execution ↗ for commit 12471388034228dab360e9c08a0290ba6427c6d2
Command Status Duration Result nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded 2m 40s View ↗ nx run-many --targets=build --exclude=examples/**✅ Succeeded 39s View ↗
☁️ Nx Cloud last updated this comment at
2026-01-08 11:55:15UTC@tanstack/ai
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@210@tanstack/ai-anthropic
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@210@tanstack/ai-client
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@210@tanstack/ai-devtools-core
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@210@tanstack/ai-gemini
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@210@tanstack/ai-grok
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok@210@tanstack/ai-ollama
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@210@tanstack/ai-openai
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@210@tanstack/ai-preact
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-preact@210@tanstack/ai-react
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@210@tanstack/ai-react-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react-ui@210@tanstack/ai-solid
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@210@tanstack/ai-solid-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid-ui@210@tanstack/ai-svelte
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-svelte@210@tanstack/ai-vue
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue@210@tanstack/ai-vue-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue-ui@210@tanstack/react-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@210@tanstack/solid-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@210commit:
1247138AlemTuzlak approved these changes
Actionable comments posted: 0
🧹 Nitpick comments (2)
.changeset/goofy-cities-push.md (1)
1-6: Changeset structure looks good; minor wording suggestion.The changeset correctly declares patch updates for both affected packages. The description could use slightly more formal wording for consistency with professional changelog entries.
✨ Optional wording improvement
-fixed an issue with gemini and thought chunks processing +Resolves an issue with Gemini and thought chunks processingexamples/ts-react-chat/src/routes/api.tanchat.ts (1)
100-104: EmptymodelOptionsis unnecessary for Grok adapter.The
modelOptions: {}on line 103 has no effect. Consider removing it to reduce noise, or this may be intentional to maintain a consistent structure across adapters.♻️ Optional: Remove empty modelOptions
grok: () => createChatOptions({ adapter: grokText((model || 'grok-3') as 'grok-3'), - modelOptions: {}, }),📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between ff584948ab5809e2f40a5054da98f8bb02ff7293 and 1613d8d2098730c774d223a975afea7c09723e7c.
📒 Files selected for processing (7)
.changeset/goofy-cities-push.mdexamples/ts-react-chat/src/lib/model-selection.tsexamples/ts-react-chat/src/routes/api.tanchat.tspackages/typescript/ai-gemini/src/adapters/text.tspackages/typescript/ai-gemini/src/model-meta.tspackages/typescript/ai-gemini/src/text/text-provider-options.tspackages/typescript/ai/src/activities/chat/stream/processor.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Use tree-shakeable adapter architecture for provider implementations - export specialized adapters (text, embedding, summarize, image) as separate imports from/adapterssubpath rather than monolithic adapters Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions withtoolDefinition()and Zod schema inference Implement isomorphic tool system usingtoolDefinition()with.server()and.client()implementations for dual-environment execution Use type-safe per-model configuration with provider options typed based on selected model to ensure compile-time safety Implement stream processing with StreamProcessor for handling chunked responses and support partial JSON parsing for streaming AI responsesFiles:
packages/typescript/ai/src/activities/chat/stream/processor.tsexamples/ts-react-chat/src/routes/api.tanchat.tsexamples/ts-react-chat/src/lib/model-selection.tspackages/typescript/ai-gemini/src/adapters/text.tspackages/typescript/ai-gemini/src/text/text-provider-options.tspackages/typescript/ai-gemini/src/model-meta.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Use camelCase for function and variable names throughout the codebase
Files:
packages/typescript/ai/src/activities/chat/stream/processor.tsexamples/ts-react-chat/src/routes/api.tanchat.tsexamples/ts-react-chat/src/lib/model-selection.tspackages/typescript/ai-gemini/src/adapters/text.tspackages/typescript/ai-gemini/src/text/text-provider-options.tspackages/typescript/ai-gemini/src/model-meta.ts
examples/**
📄 CodeRabbit inference engine (CLAUDE.md)
Examples are not built by Nx and should be run independently from their directories with
pnpm devorpnpm install && pnpm devFiles:
examples/ts-react-chat/src/routes/api.tanchat.tsexamples/ts-react-chat/src/lib/model-selection.ts
packages/typescript/*/src/adapters/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Create individual adapter implementations for each provider capability (text, embed, summarize, image) with separate exports to enable tree-shaking
Files:
packages/typescript/ai-gemini/src/adapters/text.ts
packages/typescript/*/src/model-meta.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Maintain model metadata files that define provider options and capabilities per model for per-model type safety
Files:
packages/typescript/ai-gemini/src/model-meta.ts
🧠 Learnings (7)
📚 Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR Repo: TanStack/ai PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-12-13T17:09:09.794Z Learning: Applies to **/*.{ts,tsx} : Implement stream processing with StreamProcessor for handling chunked responses and support partial JSON parsing for streaming AI responsesApplied to files:
packages/typescript/ai/src/activities/chat/stream/processor.tspackages/typescript/ai-gemini/src/adapters/text.ts
📚 Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR Repo: TanStack/ai PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-12-13T17:09:09.794Z Learning: Applies to packages/typescript/*/src/model-meta.ts : Maintain model metadata files that define provider options and capabilities per model for per-model type safetyApplied to files:
examples/ts-react-chat/src/routes/api.tanchat.tsexamples/ts-react-chat/src/lib/model-selection.tspackages/typescript/ai-gemini/src/adapters/text.tspackages/typescript/ai-gemini/src/text/text-provider-options.tspackages/typescript/ai-gemini/src/model-meta.ts
📚 Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR Repo: TanStack/ai PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-12-13T17:09:09.794Z Learning: Applies to packages/typescript/*/src/adapters/*.ts : Create individual adapter implementations for each provider capability (text, embed, summarize, image) with separate exports to enable tree-shakingApplied to files:
examples/ts-react-chat/src/routes/api.tanchat.tspackages/typescript/ai-gemini/src/adapters/text.tspackages/typescript/ai-gemini/src/text/text-provider-options.tspackages/typescript/ai-gemini/src/model-meta.ts
📚 Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR Repo: TanStack/ai PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-12-13T17:09:09.794Z Learning: Applies to packages/typescript/*/src/index.ts : Export tree-shakeable adapters with clear subpath exports in package.json (e.g., `tanstack/ai/adapters`, `tanstack/ai-openai/adapters`) to minimize bundle sizeApplied to files:
examples/ts-react-chat/src/routes/api.tanchat.tspackages/typescript/ai-gemini/src/adapters/text.tspackages/typescript/ai-gemini/src/text/text-provider-options.ts
📚 Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR Repo: TanStack/ai PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-12-13T17:09:09.794Z Learning: Applies to **/*.{ts,tsx} : Use tree-shakeable adapter architecture for provider implementations - export specialized adapters (text, embedding, summarize, image) as separate imports from `/adapters` subpath rather than monolithic adaptersApplied to files:
packages/typescript/ai-gemini/src/adapters/text.tspackages/typescript/ai-gemini/src/text/text-provider-options.ts
📚 Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR Repo: TanStack/ai PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-12-13T17:09:09.794Z Learning: Applies to **/*.{ts,tsx} : Use type-safe per-model configuration with provider options typed based on selected model to ensure compile-time safetyApplied to files:
packages/typescript/ai-gemini/src/adapters/text.tspackages/typescript/ai-gemini/src/text/text-provider-options.tspackages/typescript/ai-gemini/src/model-meta.ts
📚 Learning: 2025-12-27T20:22:51.232Z
Learnt from: harry-whorlow Repo: TanStack/ai PR: 117 File: packages/typescript/ai-ollama/src/meta/model-meta-gpt-oss.ts:92-97 Timestamp: 2025-12-27T20:22:51.232Z Learning: In the ai-ollama package's model-meta files (packages/typescript/ai-ollama/src/meta/model-meta-*.ts), capability-related comments follow a standard template format across all files for consistency, even if the comment text doesn't precisely match individual model capabilities. This is an intentional design choice to maintain uniformity across the codebase.Applied to files:
packages/typescript/ai-gemini/src/model-meta.ts
🧬 Code graph analysis (4)
examples/ts-react-chat/src/routes/api.tanchat.ts (1)
packages/typescript/ai-grok/src/adapters/text.ts (1)
grokText(500-506)
packages/typescript/ai-gemini/src/adapters/text.ts (1)
packages/typescript/ai/src/types.ts (1)
TextOptions(565-650)
packages/typescript/ai-gemini/src/text/text-provider-options.ts (3)
packages/typescript/ai-anthropic/src/text/text-provider-options.ts (1)
ExternalTextProviderOptions(111-118)
packages/typescript/ai-openai/src/text/text-provider-options.ts (1)
ExternalTextProviderOptions(237-242)
packages/typescript/ai-gemini/src/index.ts (2)
GeminiThinkingOptions(73-73)GeminiStructuredOutputOptions(72-72)
packages/typescript/ai-gemini/src/model-meta.ts (1)
packages/typescript/ai-gemini/src/text/text-provider-options.ts (5)
GeminiCommonConfigOptions(25-165)GeminiCachedContentOptions(167-172)GeminiStructuredOutputOptions(174-217)GeminiThinkingOptions(219-234)GeminiThinkingAdvancedOptions(236-246)
🪛 LanguageTool
.changeset/goofy-cities-push.md
[style] ~5-~5: Consider using a different verb for a more formal wording. Context: ...mini': patch '@tanstack/ai': patch --- fixed an issue with gemini and thought chunks...
(FIX_RESOLVE)
🔇 Additional comments (11)
packages/typescript/ai/src/activities/chat/stream/processor.ts (1)
735-745: LGTM! Correct fix for undefined delta handling.The added truthy check prevents
undefinedornulldelta from being incorrectly appended to thinking content. Without this guard,chunk.delta !== ''would evaluate totrueforundefined, causing the fallback logic on line 737-744 to be bypassed incorrectly.examples/ts-react-chat/src/lib/model-selection.ts (1)
38-42: LGTM! Model updated to support thinking features.The switch to
gemini-2.5-flashaligns with the PR's thinking support enhancements. This model is properly defined inmodel-meta.tswith thinking capabilities.packages/typescript/ai-gemini/src/text/text-provider-options.ts (2)
219-246: Well-structured composition of thinking options.The separation of
GeminiThinkingOptions(forincludeThoughtsandthinkingBudget) andGeminiThinkingAdvancedOptions(forthinkingLevel) enables clean per-model type safety. The intersection inExternalTextProviderOptionscorrectly merges boththinkingConfigshapes into a unified interface.
248-254: ExternalTextProviderOptions composition looks correct.The union properly includes
GeminiCommonConfigOptions,GeminiThinkingOptions,GeminiThinkingAdvancedOptions, andGeminiStructuredOutputOptions, aligning with the pattern used by other providers (OpenAI, Anthropic) per the relevant code snippets.packages/typescript/ai-gemini/src/model-meta.ts (4)
1-9: LGTM! Import updates align with renamed types.The imports correctly reflect the renaming of
GeminiGenerationConfigOptionstoGeminiCommonConfigOptionsand the addition ofGeminiThinkingAdvancedOptions.
78-86: Correct per-model type composition for Gemini 3 Pro.The provider options correctly include both
GeminiThinkingOptionsandGeminiThinkingAdvancedOptions, enabling both basic thinking configuration and advanced thinking level settings for this model.
912-969:GeminiChatModelProviderOptionsByNamecorrectly mirrors model definitions.The type map properly reflects which models support
GeminiThinkingAdvancedOptions(Gemini 3 models) versus those with onlyGeminiThinkingOptions(Gemini 2.5 models). This maintains compile-time type safety for per-model configurations. Based on learnings, this aligns with the pattern for per-model type safety.
189-196: Exclusion ofGeminiThinkingAdvancedOptionsfor Gemini 2.5 Pro is correct.Gemini 2.5 Pro does not support the
thinkingLevelparameter defined inGeminiThinkingAdvancedOptions. It usesthinkingBudgetinstead (supported byGeminiThinkingOptions), with a range of 128–32,768 tokens. Gemini 3 models support both parameters, hence the inclusion of both option types. The current type configuration is intentional and accurate.examples/ts-react-chat/src/routes/api.tanchat.ts (1)
93-98: Thinking configuration correctly enabled for Gemini adapter.The
modelOptionswiththinkingConfig: { includeThoughts: true, thinkingBudget: 100 }properly demonstrates the new thinking support. Note thatthinkingBudget: 100is relatively low—this may be intentional for demo purposes to keep thinking concise.packages/typescript/ai-gemini/src/adapters/text.ts (2)
216-236: Core fix: Correctly emits thinking chunks for "thought" parts.This is the main fix for issue #209. Parts with
part.thought === truenow emittype: 'thinking'chunks instead of being accumulated into content. The chunk structure includes bothcontentanddeltaset to the same value (part.text), which is appropriate since thinking parts arrive as complete units rather than accumulated.
491-519: VerifymodelOptsspreading doesn't leak unintended properties into config.Line 500 spreads
...modelOptsdirectly into theconfigobject. IfmodelOptionscontains properties that aren't valid Gemini API config fields (e.g., nestedthinkingConfigbefore it's processed), this could cause issues.The code extracts
thinkingConfigon line 495, but then spreads the entiremodelOpts(including the originalthinkingConfig) on line 500, only to override it with the processed version on lines 504-512. This results in redundant/overwritten properties.Consider extracting only the relevant properties or omitting
thinkingConfigfrom the spread:♻️ Suggested improvement
private mapCommonOptionsToGemini( options: TextOptions<GeminiTextProviderOptions>, ) { const modelOpts = options.modelOptions const thinkingConfig = modelOpts?.thinkingConfig + const { thinkingConfig: _, ...restModelOpts } = modelOpts ?? {} const requestOptions: GenerateContentParameters = { model: options.model, contents: this.formatMessages(options.messages), config: { - ...modelOpts, + ...restModelOpts, temperature: options.temperature, topP: options.topP, maxOutputTokens: options.maxTokens, thinkingConfig: thinkingConfig ? { ...thinkingConfig, thinkingLevel: thinkingConfig.thinkingLevel ? (thinkingConfig.thinkingLevel as ThinkingLevel) : undefined, } : undefined, systemInstruction: options.systemPrompts?.join('\n'), tools: convertToolsToProviderFormat(options.tools), }, } return requestOptions }Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts (1)
172-251: Critical: Structural mismatch between providerOptions definition and test expectations.The
providerOptionsobject is defined with a nestedgenerationConfigstructure (lines 174-202), but the test expectations (lines 230-251) read fields directly from the top level ofproviderOptions. This mismatch will cause the test to fail because fields likeproviderOptions?.stopSequences,providerOptions?.topK, etc., are undefined—they're actually nested atproviderOptions.generationConfig.stopSequences,providerOptions.generationConfig.topK, etc.Based on the PR's flattening of options (GeminiGenerationConfigOptions → GeminiCommonConfigOptions), the
providerOptionsobject definition should be flattened to match the expectations.🔧 Proposed fix to flatten the providerOptions definition
const providerOptions: GeminiTextProviderOptions = { safetySettings, - generationConfig: { - stopSequences: ['<done>', '###'], - responseMimeType: 'application/json', - responseSchema, - responseJsonSchema, - responseModalities: ['TEXT'], - candidateCount: 2, - topK: 6, - seed: 7, - presencePenalty: 0.2, - frequencyPenalty: 0.4, - responseLogprobs: true, - logprobs: 3, - enableEnhancedCivicAnswers: true, - speechConfig: { - voiceConfig: { - prebuiltVoiceConfig: { - voiceName: 'Studio', - }, + stopSequences: ['<done>', '###'], + responseMimeType: 'application/json', + responseSchema, + responseJsonSchema, + responseModalities: ['TEXT'], + candidateCount: 2, + topK: 6, + seed: 7, + presencePenalty: 0.2, + frequencyPenalty: 0.4, + responseLogprobs: true, + logprobs: 3, + enableEnhancedCivicAnswers: true, + speechConfig: { + voiceConfig: { + prebuiltVoiceConfig: { + voiceName: 'Studio', }, }, - thinkingConfig: { - includeThoughts: true, - thinkingBudget: 128, - }, - imageConfig: { - aspectRatio: '1:1', - }, }, + thinkingConfig: { + includeThoughts: true, + thinkingBudget: 128, + }, + imageConfig: { + aspectRatio: '1:1', + }, cachedContent: 'cachedContents/weather-context', } as const📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 1613d8d2098730c774d223a975afea7c09723e7c and 12471388034228dab360e9c08a0290ba6427c6d2.
📒 Files selected for processing (2)
packages/typescript/ai-gemini/tests/gemini-adapter.test.tspackages/typescript/ai-openai/live-tests/tool-test-empty-object.ts
💤 Files with no reviewable changes (1)
- packages/typescript/ai-openai/live-tests/tool-test-empty-object.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Use tree-shakeable adapter architecture for provider implementations - export specialized adapters (text, embedding, summarize, image) as separate imports from/adapterssubpath rather than monolithic adapters Use Zod for runtime schema validation and type inference, particularly for tool input/output definitions withtoolDefinition()and Zod schema inference Implement isomorphic tool system usingtoolDefinition()with.server()and.client()implementations for dual-environment execution Use type-safe per-model configuration with provider options typed based on selected model to ensure compile-time safety Implement stream processing with StreamProcessor for handling chunked responses and support partial JSON parsing for streaming AI responsesFiles:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Write unit tests using Vitest alongside source files with
.test.tsnaming conventionFiles:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Use camelCase for function and variable names throughout the codebase
Files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts
🧠 Learnings (5)
📚 Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR Repo: TanStack/ai PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-12-13T17:09:09.794Z Learning: Applies to packages/typescript/*/src/adapters/*.ts : Create individual adapter implementations for each provider capability (text, embed, summarize, image) with separate exports to enable tree-shakingApplied to files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts
📚 Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR Repo: TanStack/ai PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-12-13T17:09:09.794Z Learning: Applies to packages/typescript/*/src/model-meta.ts : Maintain model metadata files that define provider options and capabilities per model for per-model type safetyApplied to files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts
📚 Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR Repo: TanStack/ai PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-12-13T17:09:09.794Z Learning: Applies to packages/typescript/*/src/index.ts : Export tree-shakeable adapters with clear subpath exports in package.json (e.g., `tanstack/ai/adapters`, `tanstack/ai-openai/adapters`) to minimize bundle sizeApplied to files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts
📚 Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR Repo: TanStack/ai PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-12-13T17:09:09.794Z Learning: Applies to **/*.{ts,tsx} : Use tree-shakeable adapter architecture for provider implementations - export specialized adapters (text, embedding, summarize, image) as separate imports from `/adapters` subpath rather than monolithic adaptersApplied to files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts
📚 Learning: 2025-12-13T17:09:09.794Z
Learnt from: CR Repo: TanStack/ai PR: 0 File: CLAUDE.md:0-0 Timestamp: 2025-12-13T17:09:09.794Z Learning: Applies to **/*.{ts,tsx} : Use type-safe per-model configuration with provider options typed based on selected model to ensure compile-time safetyApplied to files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts
AlemTuzlak merged this7573619
AlemTuzlak closed this
Sign in to join this conversation.
📝 Walkthrough
Walkthrough#
Gemini text adapter streaming now emits explicit "thinking" chunks for thought parts and model/provider option shapes were flattened/expanded (GeminiGenerationConfigOptions → GeminiCommonConfigOptions; added advanced thinking options). Examples and model metadata updated; minor stream processor guard tightened and changesets added.
Changes#
\.changeset/*\.changeset/flat-buttons-shave.md,\.changeset/goofy-cities-push.md@tanstack/ai-gemini(and@tanstack/ai) describing fixes to Gemini thought/chunk processing.packages/typescript/ai-gemini/src/adapters/text.tspart.thoughtnow yield athinkingchunk (type'thinking') instead of appending to accumulated assistant content; options mapping updated to accept and mergemodelOptions(includingthinkingConfig) into request config.packages/typescript/ai-gemini/src/text/text-provider-options.ts,packages/typescript/ai-gemini/src/model-meta.tsGeminiGenerationConfigOptionsrenamed/flattened toGeminiCommonConfigOptions; addedGeminiThinkingAdvancedOptions; updated ExternalTextProviderOptions and model metadata mappings to include common config and advanced thinking options.packages/typescript/ai-gemini/tests/gemini-adapter.test.tsgenerationConfig.*to top-level provider options) and to reflectthinkingConfiglocation changes.examples/ts-react-chat/src/routes/api.tanchat.ts,examples/ts-react-chat/src/lib/model-selection.tsgemini-2.5-flash); example chat options now passmodelOptions(thinkingConfig: { includeThoughts: true, thinkingBudget: 100 }) for Gemini andmodelOptions: {}for Grok.packages/typescript/ai/src/activities/chat/stream/processor.tschunk.delta !== ''tochunk.delta && chunk.delta !== ''to avoid treating undefined/null delta as valid.packages/typescript/ai-openai/live-tests/tool-test-empty-object.tsconsole.log()in a live test.Sequence Diagram(s)#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs#
Suggested reviewers#
Poem#
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
✨ Finishing touches
📜 Recent review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 1613d8d2098730c774d223a975afea7c09723e7c and 12471388034228dab360e9c08a0290ba6427c6d2.
📒 Files selected for processing (2)
packages/typescript/ai-gemini/tests/gemini-adapter.test.tspackages/typescript/ai-openai/live-tests/tool-test-empty-object.ts💤 Files with no reviewable changes (1)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts**/*.test.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts🧠 Learnings (5)
📚 Learning: 2025-12-13T17:09:09.794Z
Applied to files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts📚 Learning: 2025-12-13T17:09:09.794Z
Applied to files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts📚 Learning: 2025-12-13T17:09:09.794Z
Applied to files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts📚 Learning: 2025-12-13T17:09:09.794Z
Applied to files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.ts📚 Learning: 2025-12-13T17:09:09.794Z
Applied to files:
packages/typescript/ai-gemini/tests/gemini-adapter.test.tsThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share