Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Nov 24, 2025

Problem

The Gemini format transformer was throwing errors when encountering unsupported content block types like reasoning, thinking, or document in conversation history, breaking threads on Vertex AI.

Solution

Changed the default case in the content block switch statement to skip unsupported blocks with a warning instead of throwing an error. This allows conversations to continue gracefully when encountering metadata blocks from other providers.

Changes

  • src/api/transform/gemini-format.ts: Skip unsupported blocks with console.warn instead of throwing
  • src/api/transform/__tests__/gemini-format.spec.ts: Updated tests to verify unsupported blocks are skipped

Testing

All 4,199 tests pass, including updated tests for graceful handling of unsupported content blocks.

- Add OPEN_ROUTER_REASONING_DETAILS_MODELS set to track models using reasoning_details array format
- Accumulate and store full reasoning_details array during streaming
- Add getReasoningDetails() method to OpenRouterHandler
- Store reasoning_details on ApiMessage type and persist to conversation history
- Set preserveReasoning: true for models in the set
- Preserve reasoning_details when converting messages to OpenAI format
- Send reasoning_details back to API on subsequent requests for tool calling workflows

Fixes upstream issue from cline/cline#7551
Follows OpenRouter docs: https://openrouter.ai/docs/use-cases/reasoning-tokens#preserving-reasoning-blocks
…roperly

- Accumulate reasoning_details chunks into complete objects (not fragments)
- Prevent double storage: only store reasoning_details OR reasoning block, never both
- Remove debug logging from openai-format.ts
- Inject fake reasoning.encrypted blocks for Gemini tool calls when switching models
- Fix priority-based format handling: check reasoning_details first, fall back to legacy reasoning
- Add ReasoningContentBlock type to handle reasoning blocks from conversation history
- Filter out reasoning blocks when converting to Gemini format
- Add test case to verify reasoning blocks are properly filtered
- Fixes 'unsupported content block type: reasoning' error on Vertex AI
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Nov 24, 2025
@roomote
Copy link
Contributor

roomote bot commented Nov 24, 2025

Rooviewer Clock   See task on Roo Cloud

Re-review completed - no new issues found. The latest changes are merge updates from main including CHANGELOG updates, Cerebras model cleanup, cloud sync improvements, and LiteLLM cache management enhancements. The core Gemini transformer fix remains sound.

Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Nov 24, 2025
- Changed default case to skip unsupported blocks (reasoning, thinking, etc.) with console.warn
- This prevents conversation threads from breaking when encountering metadata blocks
- Updated tests to verify unsupported blocks are skipped gracefully
@daniel-lxs daniel-lxs changed the title fix: support reasoning content blocks in Gemini format transformer fix: gracefully skip unsupported content blocks in Gemini transformer Nov 24, 2025
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Nov 24, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 24, 2025
@mrubens mrubens merged commit 5336246 into main Nov 24, 2025
16 checks passed
@mrubens mrubens deleted the fix/gemini-3-reasoning-details branch November 24, 2025 20:14
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Nov 24, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Nov 24, 2025
mini2s added a commit to zgsm-ai/costrict that referenced this pull request Nov 25, 2025
* ux: Home screen visuals (RooCodeInc#9057)

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: Roo Code <[email protected]>

* feat: add MiniMax-M2-Stable model and enable prompt caching (RooCodeInc#9072)

Co-authored-by: Roo Code <[email protected]>
Co-authored-by: Daniel <[email protected]>

* fix(task): auto-retry on empty assistant response (RooCodeInc#9076) (RooCodeInc#9083)

* feat(chat): Improve diff appearance in main chat view (RooCodeInc#8932)

Co-authored-by: daniel-lxs <[email protected]>

* Clarify: setting 0 disables Error & Repetition Limit (RooCodeInc#8965)

Co-authored-by: Roo Code <[email protected]>
Co-authored-by: daniel-lxs <[email protected]>

* fix: use system role for OpenAI Compatible provider when streaming is disabled (RooCodeInc#8216)

Co-authored-by: Roo Code <[email protected]>
Co-authored-by: daniel-lxs <[email protected]>

* fix: prevent shell injection in pre-push hook environment loading (RooCodeInc#9059)

* feat: auto-switch to imported mode with architect fallback (RooCodeInc#9003)

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
Co-authored-by: Seth Miller <[email protected]>
Co-authored-by: heyseth <[email protected]>
Co-authored-by: Roo Code <[email protected]>

* fix: prevent notification sound on attempt_completion with queued messages (RooCodeInc#8540)

Co-authored-by: Roo Code <[email protected]>

* chore(deps): update dependency @changesets/cli to v2.29.7 (RooCodeInc#8490)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: add changeset for v3.30.3 (RooCodeInc#9092)

* Changeset version bump (RooCodeInc#9094)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* fix: respect custom OpenRouter URL for all API operations (RooCodeInc#8951)

Co-authored-by: Roo Code <[email protected]>

* feat: Add comprehensive error logging to Roo Cloud provider (RooCodeInc#9098)

feat: add comprehensive error logging to Roo Cloud provider

- Add detailed error logging in handleOpenAIError() to capture error details before transformation
- Enhanced getRooModels() to log HTTP response details on failed requests
- Added error context logging to RooHandler streaming and model loading
- All existing tests passing (48 total)

* ux: Less Caffeine (RooCodeInc#9104)

Prevents stress on Roo's hip bones

* fix: prevent crash when streaming chunks have null choices array (RooCodeInc#9105)

* ux: Improvements to to-do lists and task headers (RooCodeInc#9096)

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* fix: prevent context condensing on settings save when provider/model unchanged (RooCodeInc#9108)

Co-authored-by: Matt Rubens <[email protected]>

* Release v3.31.0 (RooCodeInc#9111)

* Changeset version bump (RooCodeInc#9112)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* fix: improve mobile responsiveness of hero section on /reviewer page (RooCodeInc#9138)

Co-authored-by: Roo Code <[email protected]>

* feat(integrations): update export markdown filename to include 'costrict' prefix

* feat(core): enhance attempt_completion parsing with flexible result handling

* test(core): update test configurations and CSP settings

* feat: add Google Tag Manager to marketing website (RooCodeInc#9148)

* feat: add Google Tag Manager to marketing website using Next.js Script component

* refactor: remove Google Ads implementation in favor of Tag Manager

* fix: wrap GTM script in consent-checking client component for GDPR compliance

---------

Co-authored-by: Roo Code <[email protected]>

* IPC command for sending messages to the current task (RooCodeInc#9149)

* fix: prevent command_output ask from blocking in cloud/headless environments (RooCodeInc#9152)

* chore: add changeset for v3.31.1 (RooCodeInc#9153)

* Release: v1.85.0 (RooCodeInc#9155)

* Gate XML out when native tool protocol is ON (RooCodeInc#9107)

* Add native tool definitions (RooCodeInc#9156)

* feat: sync reviewer landing page copy - variant B to variant A (RooCodeInc#9158)

- Updated variant A content to match variant B messaging
- Both variants now show the same improved copy focused on catching meaningful bugs
- Emphasizes depth over token-saving and repository-aware analysis

Co-authored-by: Roo Code <[email protected]>

* feat: sync reviewer landing page copy - variant B to variant A (RooCodeInc#9158)

- Updated variant A content to match variant B messaging
- Both variants now show the same improved copy focused on catching meaningful bugs
- Emphasizes depth over token-saving and repository-aware analysis

Co-authored-by: Roo Code <[email protected]>

* Move auto-approval from `ChatView` to `Task` (RooCodeInc#9157)

* feat(i18n): add internationalization for unexpected API response error message

* fix(task): use consistent error message for API response failures and ensure message queue is never undefined

* test: update vscode mock and improve test coverage

* fix: Model switch re-applies selected profile (sync task.apiConfiguration) (RooCodeInc#9179) (RooCodeInc#9181)

* Add custom Button component with variant system (RooCodeInc#9150)

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>
Co-authored-by: Roo Code <[email protected]>

* Changeset version bump (RooCodeInc#9154)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <[email protected]>

* feat(core): detect API configuration changes for model switching

* fix: include mcpServers in getState() for auto-approval (RooCodeInc#9199)

* fix: replace rate-limited badges with badgen.net (RooCodeInc#9200)

* Batch settings updates from the webview to the extension host (RooCodeInc#9165)

Co-authored-by: Roo Code <[email protected]>

* fix: Apply updated API profile settings when provider/model unchanged (RooCodeInc#9208) (RooCodeInc#9210)

fix: apply updated API profile settings when provider/model unchanged (RooCodeInc#9208)

* fix: migrate Issue Fixer to REST + ProjectsV2 (RooCodeInc#9207)

* fix(issue-fixer): migrate to REST for issue/comments and add ProjectsV2; remove Projects Classic mentions

* Update .roo/rules-issue-fixer/4_github_cli_usage.xml

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>

* Update .roo/rules-issue-fixer/4_github_cli_usage.xml

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>

---------

Co-authored-by: roomote[bot] <219738659+roomote[bot]@users.noreply.github.com>

* Migrate conversation continuity to plugin-side encrypted reasoning items (Responses API) (RooCodeInc#9203)

* Migrate conversation continu