Skip to content

Commit f123eb3

Browse files
committed
Fix context summary output to handle cases where only tools or only messages are pruned
Previously the output would show "0 tools, 3 messages" if only messages were pruned. Now it conditionally shows both parts properly, omitting the 0-count category.
1 parent cdb5862 commit f123eb3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/commands/context.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,12 @@ function formatContextMessage(breakdown: TokenBreakdown): string {
234234

235235
if (breakdown.prunedTokens > 0) {
236236
const withoutPruning = breakdown.total + breakdown.prunedTokens
237-
const messagePrunePart =
238-
breakdown.prunedMessageCount > 0 ? `, ${breakdown.prunedMessageCount} messages` : ""
237+
const pruned = []
238+
if (breakdown.prunedCount > 0) pruned.push(`${breakdown.prunedCount} tools`)
239+
if (breakdown.prunedMessageCount > 0)
240+
pruned.push(`${breakdown.prunedMessageCount} messages`)
239241
lines.push(
240-
` Pruned: ${breakdown.prunedCount} tools${messagePrunePart} (~${formatTokenCount(breakdown.prunedTokens)})`,
242+
` Pruned: ${pruned.join(", ")} (~${formatTokenCount(breakdown.prunedTokens)})`,
241243
)
242244
lines.push(` Current context: ~${formatTokenCount(breakdown.total)}`)
243245
lines.push(` Without DCP: ~${formatTokenCount(withoutPruning)}`)

0 commit comments

Comments
 (0)