Skip to content

Python: Bug: Google AI connector leaks thinking/thought text parts into ChatMessageContent #13710

Description

@dariusFTOS

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

  1. Install semantic-kernel==1.41.1
  2. Configure GoogleAIChatCompletion with gemini-3-pro-preview
  3. Enable thinking via execution settings: thinking_config = {"include_thoughts": True}
  4. Register kernel functions/tools and enable auto function calling
  5. Send a prompt that triggers tool calls
  6. 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.

Activity

  1. added a commit that references this issue on Mar 26, 2026
    1e30f3f
  2. 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
  3. ds-brandao commented on Apr 6, 2026

    @ds-brandao

    I believe for anthropic models there is a similar implementation gap

  4. github-actions commented on Jul 6, 2026

    @github-actions
    Contributor

    This issue is stale because it has been open for 90 days with no activity.

  5. added
    staleIssue is stale because it has been open for a while and has no activity
    on Jul 6, 2026
  6. github-actions commented on Jul 21, 2026

    @github-actions
    Contributor

    This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleIssue is stale because it has been open for a while and has no activity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions