fix(core): Fix chat corruption bug in context manager. (#26534)

This commit is contained in:
joshualitt
2026-05-05 15:50:01 -07:00
committed by GitHub
parent e039fcdf2a
commit 80d2690540
8 changed files with 428 additions and 63 deletions
+3 -3
View File
@@ -149,13 +149,13 @@ export class ContextGraphBuilder {
const msg = history[turnIdx];
if (!msg.parts) continue;
// Defensive: Skip legacy environment header if it's the first turn.
// Defensive: Skip legacy environment header regardless of where it appears.
// We now manage this as an orthogonal late-addition header.
if (turnIdx === 0 && msg.role === 'user' && msg.parts.length === 1) {
if (msg.role === 'user' && msg.parts.length === 1) {
const text = msg.parts[0].text;
if (
text?.startsWith('<session_context>') &&
text?.includes('This is the Gemini CLI.')
text?.includes('This is the Gemini CLI')
) {
debugLogger.log(
'[ContextGraphBuilder] Skipping legacy environment header turn from graph.',