mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-04 04:27:29 +08:00
feat(runtime): add process watch patterns, unified backup/import, pluggable context engine, token usage, and codex device login
This commit is contained in:
26
pkg/agent/loop_usage_test.go
Normal file
26
pkg/agent/loop_usage_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/YspCoder/clawgo/pkg/providers"
|
||||
)
|
||||
|
||||
func TestMergeUsageTotals(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var result llmTurnLoopResult
|
||||
mergeUsageTotals(&result, &providers.UsageInfo{PromptTokens: 10, CompletionTokens: 4, TotalTokens: 0})
|
||||
mergeUsageTotals(&result, &providers.UsageInfo{PromptTokens: 3, CompletionTokens: 2, TotalTokens: 9})
|
||||
|
||||
if result.promptTokens != 13 {
|
||||
t.Fatalf("prompt tokens = %d, want 13", result.promptTokens)
|
||||
}
|
||||
if result.completionTokens != 6 {
|
||||
t.Fatalf("completion tokens = %d, want 6", result.completionTokens)
|
||||
}
|
||||
// First merge falls back to prompt+completion (14), second uses explicit total (9).
|
||||
if result.totalTokens != 23 {
|
||||
t.Fatalf("total tokens = %d, want 23", result.totalTokens)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user