You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: Bug: Google AI connector leaks thinking/thought text parts into ChatMessageContent #13710
Describe the bug
When using Semantic Kernel Python with Gemini 3 Pro (gemini-3-pro-preview) and thinking enabled (thinking_config: {"include_thoughts": true}), the model's internal reasoning/thinking text parts leak into the application-visible ChatMessageContent. The thinking text appears as the response content instead of the actual model answer.
This is because _create_chat_message_content and _create_streaming_chat_message_content in GoogleAIChatCompletion add all text parts to the response without checking part.thought. Gemini returns thinking parts with part.thought = True (via the google-genai SDK Part object).
The fix in #13609 correctly handled thought_signature on function call parts, but the same filtering was not applied to text parts.
To Reproduce
Install semantic-kernel==1.41.1
Configure GoogleAIChatCompletion with gemini-3-pro-preview
Enable thinking via execution settings: thinking_config = {"include_thoughts": True}
Register kernel functions/tools and enable auto function calling
Send a prompt that triggers tool calls
Observe the final ChatMessageContent — it contains the model's thinking/reasoning text (e.g. "Processing the Task Request Okay, the task creation was successful...") mixed into or replacing the actual answer
Expected behavior
Text parts where part.thought is True should be excluded from ChatMessageContent.items (or provided separately), so that only the actual model response is surfaced to the application. The raw thinking parts should still be accessible via inner_content for debugging.
Screenshots
N/A — text-based reproduction. Example leaked output:
**Processing the Task Request**
Okay, the task creation was successful; run_id is "78602cd8-...". No need to update any instance yet...
This is the model's internal reasoning, not the actual response.
Platform
Language: Python
Source: pip package semantic-kernel==1.41.1
AI model: Google Gemini 3 Pro Preview (gemini-3-pro-preview)
IDE: VS Code
OS: Windows 11 / Linux (Docker)
Additional context
The fix is to add if part.thought: continue before the if part.text: check in both _create_chat_message_content and _create_streaming_chat_message_content. See PR #13711.
changed the title [-][Python] Google AI connector leaks thinking/thought parts into ChatMessageContent[/-][+]Python: Bug: Google AI connector leaks thinking/thought text parts into ChatMessageContent[/+]on Mar 26, 2026
Activity
Python: Filter thought parts from Google AI chat completion responses
[-][Python] Google AI connector leaks thinking/thought parts into ChatMessageContent[/-][+]Python: Bug: Google AI connector leaks thinking/thought text parts into ChatMessageContent[/+]ds-brandao commentedon Apr 6, 2026
I believe for anthropic models there is a similar implementation gap
github-actions commentedon Jul 6, 2026
This issue is stale because it has been open for 90 days with no activity.
github-actions commentedon Jul 21, 2026
This issue was closed because it has been inactive for 14 days since being marked as stale.