File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -408,10 +408,18 @@ export function createCompressTool(ctx: ToolContext): ReturnType<typeof tool> {
408408
409409 // Build token weight map for all messages (for proportional bar graph)
410410 const weights = new Map < string , number > ( )
411+ let contentWeight = 0
411412 for ( const msg of messages ) {
412- weights . set ( msg . info . id , countAllMessageTokens ( msg ) )
413+ const w = countAllMessageTokens ( msg )
414+ weights . set ( msg . info . id , w )
415+ contentWeight += w
413416 }
414417
418+ // System prompt = API total minus message content
419+ const systemWeight = Math . max ( 0 , totalSessionTokens - contentWeight )
420+ const sessionIds = [ "__system__" , ...messages . map ( ( m ) => m . info . id ) ]
421+ weights . set ( "__system__" , systemWeight )
422+
415423 await sendCompressNotification (
416424 client ,
417425 logger ,
@@ -425,7 +433,7 @@ export function createCompressTool(ctx: ToolContext): ReturnType<typeof tool> {
425433 summaryTokens ,
426434 totalSessionTokens ,
427435 estimatedCompressedTokens ,
428- messages . map ( ( m ) => m . info . id ) ,
436+ sessionIds ,
429437 weights ,
430438 messages . length ,
431439 currentParams ,
Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ export function formatSessionMap(
216216 if ( prunedMessages . has ( messageIds [ m ] ) ) {
217217 const start = Math . floor ( ( cum [ m ] / totalWeight ) * width )
218218 const end = Math . floor ( ( cum [ m + 1 ] / totalWeight ) * width )
219- const char = newPrunedIds . has ( messageIds [ m ] ) ? "▓ " : "░"
219+ const char = newPrunedIds . has ( messageIds [ m ] ) ? "⣿ " : "░"
220220 for ( let i = start ; i < end ; i ++ ) {
221221 bar [ i ] = char
222222 }
You can’t perform that action at this time.
0 commit comments