mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
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:
@@ -1396,6 +1396,7 @@ func setContextUsagePayload(payload map[string]any, u *bus.ContextUsage) {
|
||||
payload["context_usage"] = map[string]any{
|
||||
"used_tokens": u.UsedTokens,
|
||||
"total_tokens": u.TotalTokens,
|
||||
"history_tokens": u.HistoryTokens,
|
||||
"compress_at_tokens": u.CompressAtTokens,
|
||||
"summarize_at_tokens": u.SummarizeAtTokens,
|
||||
"used_percent": u.UsedPercent,
|
||||
|
||||
@@ -604,6 +604,7 @@ func TestBeginStream_FinalizeIncludesContextUsage(t *testing.T) {
|
||||
if err := contextStreamer.FinalizeWithContext(context.Background(), "final", &bus.ContextUsage{
|
||||
UsedTokens: 10,
|
||||
TotalTokens: 100,
|
||||
HistoryTokens: 5,
|
||||
CompressAtTokens: 80,
|
||||
SummarizeAtTokens: 60,
|
||||
UsedPercent: 10,
|
||||
@@ -628,6 +629,9 @@ func TestBeginStream_FinalizeIncludesContextUsage(t *testing.T) {
|
||||
if got := rawUsage["used_tokens"]; got != float64(10) {
|
||||
t.Fatalf("used_tokens = %#v, want 10", got)
|
||||
}
|
||||
if got := rawUsage["history_tokens"]; got != float64(5) {
|
||||
t.Fatalf("history_tokens = %#v, want 5", got)
|
||||
}
|
||||
if got := rawUsage["summarize_at_tokens"]; got != float64(60) {
|
||||
t.Fatalf("summarize_at_tokens = %#v, want 60", got)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user