fix(context): expose history tokens and remove leaked state files

Address remaining review feedback: 1) Add HistoryTokens field to ContextUsage/ContextStats, showing history-only token count in /context and frontend UI alongside SummarizeAtTokens so users can see the actual summarization trigger comparison. 2) Remove .codebuddy/github-contribute/ state files accidentally included in the PR.
This commit is contained in:
程智超0668000959
2026-06-06 00:28:32 +08:00
parent b6030f054d
commit 7a7e205cc8
15 changed files with 25 additions and 90 deletions
+2 -1
View File
@@ -30,11 +30,12 @@ func formatContextStats(s *ContextStats) string {
}
usedWindowPercent := s.UsedTokens * 100 / max(s.TotalTokens, 1)
msg := fmt.Sprintf(
"Context usage \nMessages: %d \nUsed: ~%d / %d tokens (%d%%) \nCompress at: %d tokens \nSummarize at: %d tokens \nCompression progress: %d%% \nRemaining: ~%d tokens",
"Context usage \nMessages: %d \nUsed: ~%d / %d tokens (%d%%) \nHistory: ~%d tokens \nCompress at: %d tokens \nSummarize at: %d tokens \nCompression progress: %d%% \nRemaining: ~%d tokens",
s.MessageCount,
s.UsedTokens,
s.TotalTokens,
usedWindowPercent,
s.HistoryTokens,
s.CompressAtTokens,
s.SummarizeAtTokens,
s.UsedPercent,
+1
View File
@@ -31,6 +31,7 @@ type MCPToolInfo struct {
type ContextStats struct {
UsedTokens int
TotalTokens int // model context window
HistoryTokens int // history-only tokens (what maybeSummarize checks)
CompressAtTokens int // hard budget compression threshold
SummarizeAtTokens int // soft summarization trigger
UsedPercent int // 0-100