Skip to content

fix(gemini): preserve multipart thought summaries - #2831

Merged
llc1123 merged 1 commit into
looplj:unstablefrom
remote-controlled-man:codex/prflow-ea42f6107f67
Nov 2, 2026
Merged

llc1123 merged 1 commit into
looplj:unstablefrom
remote-controlled-man:codex/prflow-ea42f6107f67

Conversation

@remote-controlled-man

@remote-controlled-man remote-controlled-man commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When one Gemini candidate contains several thought: true text parts, response conversion overwrites the accumulated reasoning with each part. Clients receive only the final summary fragment in both normal responses and streaming chunks.

Change

Concatenate thought text in source order in the shared response converter. The regression exercises the public response and stream interfaces with multiple parts, interleaved answer text, Unicode, an empty thought part, a separate candidate, and a subsequent streaming chunk.

This follows Google's documented iteration and accumulation of thought summaries.

Validation

  • make test-backend-all (root and llm modules).
  • cd llm && go test -race ./transformer/gemini -count=1.
  • pnpm --dir frontend test:unit.
  • go tool govulncheck ./... in both root and llm modules: no reachable vulnerabilities; each scan notes one advisory in a required module whose affected code is not called.
  • Go formatting and git diff --check.

The new regression fails in both modes before the fix and passes afterward. Per AGENTS.md, build and lint commands were not run locally; remote CI is pending.

Prepared with AI assistance and independently reviewed.

Summary by CodeRabbit

  • Bug Fixes
    • Responses now retain and combine thought text when it arrives in multiple parts, instead of losing earlier parts. Ordinary response text remains separate, and content, completion reasons, and usage counts are preserved across standard and streaming responses.

Copilot AI balanced review requested due to automatic review settings November 1, 2026 14:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8872ee1a-5da0-40cf-8538-648513fb4661
Commits

Reviewing files that changed from the base of the PR and between b941556 and 9d8e8a0.

Files selected for processing: 2
  • llm/transformer/gemini/outbound_convert.go
  • llm/transformer/gemini/outbound_stream_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

Gemini outbound conversions now append thought text parts to accumulated reasoning content. Tests cover multipart thoughts in response and streaming transformations.

Changes: Gemini thought conversion

Layer / File(s) Summary
Accumulate thought text
llm/transformer/gemini/outbound_convert.go, llm/transformer/gemini/outbound_stream_test.go
Thought text parts append to accumulated reasoning content. Tests check that response and streaming transformations combine thought text while keeping ordinary text separate, and preserve candidate content, finish reasons, and usage counts.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: looplj

Merge Risk: Minimal · up to 9d8e8

Multipart reasoning summaries should be preserved. No merge-blocking risk was identified; CI remains pending.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preserving multipart Gemini thought summaries.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks 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

@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Preserves every thought-text part in source order instead of keeping only the last part.

  • Gemini responses keep all thought parts from each candidate.

Reviews (1) · Last reviewed commit: "fix(gemini): preserve multipart thought ..." · Reviewed by Greptile

@llc1123
llc1123 merged commit 9e8b494 into looplj:unstable Nov 2, 2026
11 checks passed
Edint386 added a commit to Edint386/axonhub that referenced this pull request Nov 2, 2026
- chore: sync model developers data (looplj#2829)
- feat: add provider quota state change webhook events (looplj#2828)
- chore(deps): bump @google/genai in /integration_test/gemini/node (looplj#2837)
- chore(deps): bump @hookform/resolvers from 5.2.2 to 6.0.2 in /frontend (looplj#2835)
- chore(deps): bump google.golang.org/genai in /integration_test/gemini (looplj#2836)
- chore(deps): bump js-cookie from 3.0.7 to 3.0.8 in /frontend (looplj#2834)
- chore(deps): bump @radix-ui/react-tabs from 1.1.13 to 1.2.1 in /frontend (looplj#2833)
- chore(deps): bump @radix-ui/react-separator in /frontend (looplj#2832)
- fix(openai): preserve explicit image response format (looplj#2838)
- fix(gemini): preserve multipart thought summaries (looplj#2831)
- chore(deps): bump github.com/jackc/pgx/v5 in / (looplj#2818)
- chore(deps): bump github.com/aws/aws-sdk-go-v2/config in / (looplj#2816)
- chore(deps): bump github.com/openai/openai-go/v3 (looplj#2815)
- chore(deps): bump github.com/redis/go-redis/v9 in / (looplj#2820)
- fix(gql): preserve dashboard helpers during generation (looplj#2830)
- fix(anthropic): apply repaired tool input in stream aggregation (looplj#2827)
- fix(gemini): map blocked finish reasons to content_filter (looplj#2826)
- feat(overrides): delete fields across request body arrays (looplj#2824)
- chore(deps): bump github.com/aws/aws-sdk-go-v2/credentials in / (looplj#2817)
- fix(gemini): accept GenerateContent field aliases (looplj#2798)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants