Skip to content

feat: parse out thought summary from gemini models' response when include thought is true#1521

Merged
yuzisun merged 7 commits intoenvoyproxy:mainfrom
hustxiayang:include-thought-summary
Nov 30, 2025
Merged

feat: parse out thought summary from gemini models' response when include thought is true#1521
yuzisun merged 7 commits intoenvoyproxy:mainfrom
hustxiayang:include-thought-summary

Conversation

@hustxiayang
Copy link
Copy Markdown
Contributor

@hustxiayang hustxiayang commented Nov 9, 2025

Description

When includeThought is true, Gemini would also generate summary of thinking process. We need to parse out this kind of data to users. Otherwise, we would return thought process together with output to users.

Depends/base or replace #1461

@hustxiayang hustxiayang requested a review from a team as a code owner November 9, 2025 18:09
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Nov 9, 2025
yuzisun pushed a commit that referenced this pull request Nov 21, 2025
#1554)

**Description**
Some new features were introduced in gemini3:
**1 thinking_level:**

https://ai.google.dev/gemini-api/docs/gemini-3?thinking=low#thinking_level
This is similar to reasoning_effort of openai, thus, unified them.

**2 media_resolution**

https://ai.google.dev/gemini-api/docs/gemini-3?thinking=low#media_resolution
This is similar to detail in openai, thus, unified them.

The difference is that openai does not provide a global config of
media_resolution. Thus, added it as gcp specific, but still use detail
to make the name consistent.

**Some related PRs:**
thinking_budget is in
#1461
thinking_level and thinking_budget are both supported, but can not use
them together.

Other features under review:
**1 web search:**
#1526

**2 parse the thought summary:**
#1521

---------

Signed-off-by: yxia216 <yxia216@bloomberg.net>
Signed-off-by: Alexa Griffith <agriffith50@bloomberg.net>
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
Co-authored-by: Alexa Griffith <agriffith50@bloomberg.net>
Co-authored-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
Co-authored-by: Ignasi Barrera <ignasi@tetrate.io>
thoughtSummary, content := extractTextAndThoughtSummaryFromGeminiParts(candidate.Content.Parts, responseMode)
if thoughtSummary != "" {
message.ReasoningContent = &openai.ReasoningContentUnion{
Value: &openai.AWSBedrockReasoningContent{
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.

since reasoning content is also used by gemini now, we should remove the AWSBedrock naming prefix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@yuzisun I removed the AWSBedrock prefix in stream and non-stream

@yuzisun
Copy link
Copy Markdown
Contributor

yuzisun commented Nov 29, 2025

@hustxiayang can you help resolve the conflicts here

Signed-off-by: yxia216 <yxia216@bloomberg.net>
Signed-off-by: yxia216 <yxia216@bloomberg.net>
Signed-off-by: yxia216 <yxia216@bloomberg.net>
Signed-off-by: yxia216 <yxia216@bloomberg.net>
@hustxiayang hustxiayang force-pushed the include-thought-summary branch from bf5311b to 02d460e Compare November 30, 2025 00:04
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Nov 30, 2025
Signed-off-by: yxia216 <yxia216@bloomberg.net>
Signed-off-by: yxia216 <yxia216@bloomberg.net>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.05%. Comparing base (96a2fdd) to head (aa9ebcd).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1521      +/-   ##
==========================================
+ Coverage   84.03%   84.05%   +0.02%     
==========================================
  Files         141      141              
  Lines       13039    13056      +17     
==========================================
+ Hits        10957    10974      +17     
  Misses       1460     1460              
  Partials      622      622              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: yxia216 <yxia216@bloomberg.net>
@yuzisun yuzisun merged commit 4e7d496 into envoyproxy:main Nov 30, 2025
30 checks passed
missBerg pushed a commit to missBerg/ai-gateway that referenced this pull request Dec 20, 2025
envoyproxy#1554)

**Description**
Some new features were introduced in gemini3:
**1 thinking_level:**

https://ai.google.dev/gemini-api/docs/gemini-3?thinking=low#thinking_level
This is similar to reasoning_effort of openai, thus, unified them.

**2 media_resolution**

https://ai.google.dev/gemini-api/docs/gemini-3?thinking=low#media_resolution
This is similar to detail in openai, thus, unified them.

The difference is that openai does not provide a global config of
media_resolution. Thus, added it as gcp specific, but still use detail
to make the name consistent.

**Some related PRs:**
thinking_budget is in
envoyproxy#1461
thinking_level and thinking_budget are both supported, but can not use
them together.

Other features under review:
**1 web search:**
envoyproxy#1526

**2 parse the thought summary:**
envoyproxy#1521

---------

Signed-off-by: yxia216 <yxia216@bloomberg.net>
Signed-off-by: Alexa Griffith <agriffith50@bloomberg.net>
Signed-off-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
Co-authored-by: Alexa Griffith <agriffith50@bloomberg.net>
Co-authored-by: Sukumar Gaonkar <sgaonkar4@bloomberg.net>
Co-authored-by: Ignasi Barrera <ignasi@tetrate.io>
Signed-off-by: Erica Hughberg <erica.sundberg.90@gmail.com>
missBerg pushed a commit to missBerg/ai-gateway that referenced this pull request Dec 20, 2025
…lude thought is true (envoyproxy#1521)

**Description**

When `includeThought` is true, Gemini would also generate summary of
thinking process. We need to parse out this kind of data to users.
Otherwise, we would return thought process together with output to
users.

Depends/base or replace
envoyproxy#1461

---------

Signed-off-by: yxia216 <yxia216@bloomberg.net>
Signed-off-by: Erica Hughberg <erica.sundberg.90@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants