mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-07-25 18:19:19 +00:00
- Add TokenCounter.CountToolSchemas() to measure JSON schema size for all tools - Include tool schemas in OverheadTokens calculation for accurate context usage - Implement dynamic max_tokens: in/25 clamp [1024, 8192] for compaction - Add characterization tests: count_tool_schemas_test.go - Add overhead verification tests: context_stage_overhead_test.go, context_stage_tool_overhead_test.go - Add integration tests: context_stage_integration_test.go - Add compact tests: loop_compact_dynamic_max_test.go, loop_compact_max_tokens_test.go - Add sanitize tests: loop_history_sanitize_max_tokens_test.go - Add integration test: loop_compact_integration_test.go
27 lines
805 B
Go
27 lines
805 B
Go
package agent
|
|
|
|
import "testing"
|
|
|
|
// TestDynamicSummaryMax validates boundary cases for dynamicSummaryMax.
|
|
// Formula: out = in/25, clamped to [1024, 8192].
|
|
func TestDynamicSummaryMax(t *testing.T) {
|
|
cases := []struct {
|
|
input int
|
|
want int
|
|
}{
|
|
{0, 1024}, // zero → floor
|
|
{20000, 1024}, // 20000/25=800 → below floor, clamped
|
|
{25000, 1024}, // 25000/25=1000 → below floor, clamped
|
|
{26000, 1040}, // 26000/25=1040 → just above floor
|
|
{100000, 4000}, // 100000/25=4000 → mid-range
|
|
{204800, 8192}, // 204800/25=8192 → exactly at cap
|
|
{500000, 8192}, // 500000/25=20000 → above cap, clamped
|
|
}
|
|
for _, tc := range cases {
|
|
got := dynamicSummaryMax(tc.input)
|
|
if got != tc.want {
|
|
t.Errorf("dynamicSummaryMax(%d) = %d, want %d", tc.input, got, tc.want)
|
|
}
|
|
}
|
|
}
|