From 9e35eef3367396c66da79cdee1727d7599e8e99f Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 10 Oct 2026 14:52:47 +0800 Subject: [PATCH] gateway: TestKimiHeldBurstTellsNoSpeed waits long enough that one pause of the runner mid-burst no longer reads the held call as a speed (#1469) The test timed its replies over a wait shortened from John's (first content at 1.3 s, the end at 4 s). The held call is told held when its flow (~245 ms for the 236 ms burst) is under a quarter of its window from its first text (usage.HeldShare); a 2.5 s window put that bound at ~620 ms, so a single pause of ~400 ms that split the burst crossed it. macOS CI under -race read flow 856 ms, ms 4517 (517 ms late) and 176 tok/s: one ~520 ms pause mid-burst. Reproduced by injecting the pause (not rerunning): a 520 ms sleep in the fake before the 25th write of the chat held call read 182 tok/s, flow 773, ms 4405, as CI did. The classifier is right about such a stream; the fixture sat too near its threshold. The wait is now first content at 0.5 s and the end at 7 s: a 6.3 s window bounds flow at ~1.6 s, and the steady 50 tok/s reply stays within its 20% with a pause as long. Run: - injected 1 s pause in the chat held call, held answer, steady, and in all nine replies: ok each; a 2 s pause still fails the held call (flow 2621), so the bound is where the comment says. - break by hand: HeldShare check off -> the three held calls read 84 tok/s, red; ThinkPace check off -> the three held answers read ~2,237 tok/s, red. - go test -race -count=10 -run '^TestKimiHeldBurst' ./internal/gateway/ ok. - gofmt -l clean; go vet darwin/linux/windows ./internal/gateway/ ok. --- internal/gateway/held_speed_test.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/internal/gateway/held_speed_test.go b/internal/gateway/held_speed_test.go index 083f53d38..5e866f077 100644 --- a/internal/gateway/held_speed_test.go +++ b/internal/gateway/held_speed_test.go @@ -133,12 +133,22 @@ var kimiShapes = []kimiShape{ // The reply's speed as each agent's protocol has it, through the real // gateway from a fake Kimi Code: the held replies tell none, the steady one -// its 50 tok/s. The wait is shorter than John's (first content at 1.3 s, -// the end at 4 s) to keep the test short; the burst is his, 236 ms. +// its 50 tok/s. The wait is shorter than John's (first content at 0.5 s, +// the end at 7 s) to keep the test short; the burst is his, 236 ms. // Before, the held call read 1,790 tok/s and the held answer 2,237. +// +// The wait is still long enough that a pause of the machine running it +// doesn't change what the replies tell. The held call is told held by its +// flow (~245 ms) under a quarter of its window from its first text +// (usage.HeldShare): a window of 6.3 s takes a flow under ~1.6 s, so the +// burst can be split by a pause of a second and still tell none. The +// steady one, timed over the same window, stays within its 20% with a +// pause as long. With the end at 4 s and the first content at 1.3 s (a +// window of 2.5 s), one pause of ~520 ms mid-burst on macOS CI under +// -race read the held call at 176 tok/s (#1469). func TestKimiHeldBurstTellsNoSpeed(t *testing.T) { fresh(t) - const first, end = 1300 * time.Millisecond, 4000 * time.Millisecond + const first, end = 500 * time.Millisecond, 7000 * time.Millisecond agents := []struct{ path, body string }{ {"/v1/chat/completions", `{"model":"kimi-code/%s","stream":true,"stream_options":{"include_usage":true},"messages":[{"role":"user","content":"write the file"}],"tools":[{"type":"function","function":{"name":"write","parameters":{"type":"object","properties":{"content":{"type":"string"}}}}}]}`}, {"/v1/responses", `{"model":"kimi-code/%s","stream":true,"input":"write the file","tools":[{"type":"function","name":"write","parameters":{"type":"object","properties":{"content":{"type":"string"}}}}]}`},