Skip to content

bug: Code Assist session resume leaks [Thought: true] as literal text in model responses #23046

Closed as not planned

Description

@seheepeak

What happened?

After resuming a session (gemini --resume) with Code Assist auth (Google OAuth login), the model starts emitting [Thought: true] as literal text inside its responses. The contamination self-propagates: each subsequent turn makes it worse, and after a few turns every model response contains the marker.

Root cause chain:

  1. Session resume → convertSessionToClientHistory() reconstructs model history including {thought: true, text: '...'} parts from saved msg.thoughts summaries (introduced in v0.34.0)
  2. For Code Assist users, these parts then pass through toPart() in converter.ts, which converts {thought: true, text: 'desc'} → {text: 'desc\n[Thought: true]'} (proto oneof compatibility handling for the Code Assist API)
  3. Code Assist API receives corrupted model history with \n[Thought: true] as regular model text
  4. In-context learning: model learns to append \n[Thought: true] to its own responses
  5. Response comes back without thought: true flag → stored as regular content in session file → loop repeats

Affected users: Code Assist (OAuth login) users only. API key users (Direct Gemini) bypass converter.ts entirely and are unaffected.

The fix is a one-line change in toContent() in converter.ts: the comment already says // handle thought filtering but the filter predicate for thought: true parts was missing.

// Before (buggy):
? toParts(content.parts.filter((p) => p != null))

// After:
? toParts(content.parts.filter((p) => p != null && !p.thought))

What did you expect to happen?

Model responses should not contain [Thought: true] as literal text after session resume.

Client information

Client Information

Reproduced on v0.34.0, Code Assist auth (Google OAuth), Linux.

Login information

Google OAuth (Code Assist / LOGIN_WITH_GOOGLE)

Anything else we need to know?

Note: thought context cannot be meaningfully restored for Code Assist on session resume regardless — thoughtSignature on live response parts is the only valid carrier of thinking context for this API path (Genai and Vertex use incompatible encryption), and it is not stored in session files. So filtering the thought parts is the correct behavior, not just a workaround.

A fix PR is ready.

Activity

  1. added
    status/need-triageIssues that need to be triaged by the triage automation.
    area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Quality
    on Mar 19, 2026
  2. added 5 commits that reference this issue on Mar 28, 2026
    b1185a2
    ccbb8b8
    6567975
    3e879a8
    70b9d1d
  3. added
    area/coreIssues related to User Interface, OS Support, Core Functionality
    effort/small1 day or less: trivial logic, UI adjustments, docs
    on May 9, 2026
  4. gemini-cli commented on May 9, 2026

    @gemini-cli
    Contributor

    The issue describes an internal state leakage bug during session reconstruction.

    Effort Analysis:
    Based on the issue description and file search, the bug is a single-file logic error located in packages/core/src/code_assist/converter.ts. The fix involves a trivial logic adjustment to the toContent() function by adding a filter predicate (!p.thought) to correctly filter out thought: true parts during session resume for Code Assist users. This aligns with the effort/small categorization for highly localized bug fixes.

  5. added theissue type on May 9, 2026
  6. added
    priority/p2Important but can be addressed in a future release.
    on May 13, 2026
  7. gemini-cli commented on May 13, 2026

    @gemini-cli
    Contributor

    Thought leakage in responses affects experience but is workable.

  8. removed
    area/coreIssues related to User Interface, OS Support, Core Functionality
    on May 14, 2026
  9. gemini-cli commented on Jul 14, 2026

    @gemini-cli
    Contributor

    This bug report has been automatically marked as stale due to 60 days of inactivity. Many issues are resolved in newer releases. Please verify if the issue persists in the latest Gemini CLI version. If it does, please leave a comment to keep this open. It will be closed in 14 days if no further activity occurs. Thank you!

  10. gemini-cli commented on Jul 29, 2026

    @gemini-cli
    Contributor

    This item has been closed due to 14 additional days of inactivity after being marked as stale. If you believe this is still relevant, feel free to comment or reopen. Thank you!

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

    Stalearea/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualityeffort/small1 day or less: trivial logic, UI adjustments, docskind/bugpriority/p2Important but can be addressed in a future release.status/bot-triaged

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions