Repository navigation
bug: Code Assist session resume leaks [Thought: true] as literal text in model responses #23046
Description
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:
- Session resume →
convertSessionToClientHistory()reconstructs model history including{thought: true, text: '...'}parts from savedmsg.thoughtssummaries (introduced in v0.34.0) - For Code Assist users, these parts then pass through
toPart()inconverter.ts, which converts{thought: true, text: 'desc'}→{text: 'desc\n[Thought: true]'}(protooneofcompatibility handling for the Code Assist API) - Code Assist API receives corrupted model history with
\n[Thought: true]as regular model text - In-context learning: model learns to append
\n[Thought: true]to its own responses - Response comes back without
thought: trueflag → 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.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsClosed
Activity
fix(core): preserve structured thoughts during session resume
fix(core): preserve structured thoughts during session resume
fix(core): preserve structured thoughts during session resume
fix(core): preserve structured thoughts during session resume
fix(core): preserve structured thoughts during session resume (google…
gemini-cli commentedon May 9, 2026
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.
gemini-cli commentedon May 13, 2026
Thought leakage in responses affects experience but is workable.
gemini-cli commentedon Jul 14, 2026
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!
gemini-cli commentedon Jul 29, 2026
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!