@@ -194,6 +194,22 @@ interface VisionResolutionStats {
194194 visionModelId ?: string ;
195195}
196196
197+ interface HostPromptTrace {
198+ hostFreezeCustomizationsIndex : boolean | 'unknown' ;
199+ systemMessageIndex : number | null ;
200+ systemRole : string | null ;
201+ systemChars : number ;
202+ systemLines : number ;
203+ systemHash : string | null ;
204+ hasSkillsTag : boolean ;
205+ hasAgentsTag : boolean ;
206+ skillTagCount : number ;
207+ agentTagCount : number ;
208+ customizationsUpdateCount : number ;
209+ latestUserMessageIndex : number | null ;
210+ latestUserHasCustomizationsUpdate : boolean ;
211+ }
212+
197213class DefaultCacheDiagnosticsRecorder implements CacheDiagnosticsRecorder {
198214 private readonly previousCacheTraces = new Map < string , CacheTraceSnapshot > ( ) ;
199215 private lastCacheTrace : CacheTraceSnapshot | undefined ;
@@ -243,6 +259,11 @@ class DefaultCacheDiagnosticsRecorder implements CacheDiagnosticsRecorder {
243259 ` inputMessages=${ options . inputMessages . length } ` +
244260 ` deepseekMessages=${ options . request . messages . length } ` ,
245261 ) ;
262+ logger . info (
263+ `[cache-trace #${ requestId } ] ${ formatHostPromptTrace (
264+ summarizeHostPromptTrace ( options . inputMessages ) ,
265+ ) } `,
266+ ) ;
246267 const vscodeMessageTrace = formatVscodeMessageTrace ( options . inputMessages ) ;
247268 if ( vscodeMessageTrace ) {
248269 logger . info ( `[cache-trace #${ requestId } ] vscodeMsgs ${ vscodeMessageTrace } ` ) ;
@@ -398,6 +419,73 @@ function formatSegmentMarkerReport(info: SegmentMarkerReportInfo): string {
398419 ) ;
399420}
400421
422+ function summarizeHostPromptTrace (
423+ messages : readonly vscode . LanguageModelChatRequestMessage [ ] ,
424+ ) : HostPromptTrace {
425+ let customizationsUpdateCount = 0 ;
426+ let latestUserMessageIndex : number | null = null ;
427+ let latestUserHasCustomizationsUpdate = false ;
428+
429+ for ( const [ index , message ] of messages . entries ( ) ) {
430+ const text = getMessageText ( message ) ;
431+ customizationsUpdateCount += countLiteral ( text , '<customizationsUpdate>' ) ;
432+ if ( message . role === vscode . LanguageModelChatMessageRole . User ) {
433+ latestUserMessageIndex = index ;
434+ latestUserHasCustomizationsUpdate = text . includes ( '<customizationsUpdate>' ) ;
435+ }
436+ }
437+
438+ const systemMessage = messages [ 0 ] ;
439+ const systemText = systemMessage ? getMessageText ( systemMessage ) : '' ;
440+
441+ return {
442+ hostFreezeCustomizationsIndex : getHostFreezeCustomizationsIndex ( ) ,
443+ systemMessageIndex : systemMessage ? 0 : null ,
444+ systemRole : systemMessage ? formatVscodeMessageRole ( systemMessage . role ) : null ,
445+ systemChars : systemText . length ,
446+ systemLines : countLines ( systemText ) ,
447+ systemHash : systemMessage ? hashString ( systemText ) : null ,
448+ hasSkillsTag : systemText . includes ( '<skills>' ) ,
449+ hasAgentsTag : systemText . includes ( '<agents>' ) ,
450+ skillTagCount : countLiteral ( systemText , '<skill>' ) ,
451+ agentTagCount : countLiteral ( systemText , '<agent>' ) ,
452+ customizationsUpdateCount,
453+ latestUserMessageIndex,
454+ latestUserHasCustomizationsUpdate,
455+ } ;
456+ }
457+
458+ function getHostFreezeCustomizationsIndex ( ) : boolean | 'unknown' {
459+ const value = vscode . workspace
460+ . getConfiguration ( 'github.copilot.chat' )
461+ . get < unknown > ( 'freezeCustomizationsIndex' ) ;
462+ return typeof value === 'boolean' ? value : 'unknown' ;
463+ }
464+
465+ function formatHostPromptTrace ( trace : HostPromptTrace ) : string {
466+ const systemPrompt =
467+ trace . systemMessageIndex === null
468+ ? 'systemPrompt=none'
469+ : `systemPrompt#${ trace . systemMessageIndex } :${ trace . systemRole } ` +
470+ `:chars=${ trace . systemChars } ` +
471+ `:lines=${ trace . systemLines } ` +
472+ `:hash=${ trace . systemHash ?? 'none' } ` +
473+ `:skills=${ formatYesNo ( trace . hasSkillsTag ) } (${ trace . skillTagCount } )` +
474+ `:agents=${ formatYesNo ( trace . hasAgentsTag ) } (${ trace . agentTagCount } )` ;
475+
476+ return (
477+ `hostFreezeCustomizationsIndex=${ trace . hostFreezeCustomizationsIndex } ` +
478+ ` ${ systemPrompt } ` +
479+ ` customizationsUpdate=${ trace . customizationsUpdateCount } ` +
480+ ` latestUser#${ trace . latestUserMessageIndex ?? 'none' } =` +
481+ formatYesNo ( trace . latestUserHasCustomizationsUpdate )
482+ ) ;
483+ }
484+
485+ function formatYesNo ( value : boolean ) : 'yes' | 'no' {
486+ return value ? 'yes' : 'no' ;
487+ }
488+
401489function formatError ( error : unknown ) : string {
402490 if ( error instanceof Error ) {
403491 return sanitizeLogValue ( error . message || error . name ) ;
0 commit comments