@@ -48,7 +48,7 @@ import { ChatSessionStore, IChatSessionEntryMetadata } from '../model/chatSessio
4848import { IChatSlashCommandService } from '../participants/chatSlashCommands.js' ;
4949import { IChatTransferService } from '../model/chatTransferService.js' ;
5050import { chatSessionResourceToId , getChatSessionType , isUntitledChatSession , LocalChatSessionUri } from '../model/chatUri.js' ;
51- import { ChatRequestVariableSet , IChatRequestVariableEntry } from '../attachments/chatVariableEntries.js' ;
51+ import { ChatRequestVariableSet , IChatRequestVariableEntry , isPromptTextVariableEntry } from '../attachments/chatVariableEntries.js' ;
5252import { ChatAgentLocation , ChatModeKind } from '../constants.js' ;
5353import { ChatMessageRole , IChatMessage , ILanguageModelsService } from '../languageModels.js' ;
5454import { ILanguageModelToolsService } from '../tools/languageModelToolsService.js' ;
@@ -1171,8 +1171,17 @@ export class ChatService extends Disposable implements IChatService {
11711171 if ( instructionEntries . length > 0 ) {
11721172 allContext . push ( ...instructionEntries ) ;
11731173 }
1174+
1175+ // Store only non-instruction variables on the model.
1176+ // Automatically-added promptText entries (~33 KB each) are
1177+ // ephemeral — re-collected every turn, never rendered in
1178+ // the UI, and not needed in serialized session history.
1179+ const storedVariables = allContext . filter ( v => ! ( isPromptTextVariableEntry ( v ) && v . automaticallyAdded ) ) ;
1180+ model . updateRequest ( request , { variables : storedVariables } ) ;
1181+
1182+ // The full set (including instructions) is passed to the
1183+ // agent request only — not stored on the request model.
11741184 let variableData : IChatRequestVariableData = { variables : allContext } ;
1175- model . updateRequest ( request , variableData ) ;
11761185
11771186 // Merge resolved variables (e.g. images from directories) for the
11781187 // agent request only - they are not stored on the request model.
0 commit comments