mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-04 10:13:16 +00:00
Server-side webhook agent runs (sync, async, and admin test) used Stream:false, so OpenAI-compatible routers that only cache streaming requests never populated or served their prompt cache. Webhook runs paid full input-token price on every turn even with a stable session and an identical multi-turn prefix, while WS chat (Stream:true) got cache hits from the 3rd turn. Add gateway.webhook_stream (default true, env GOCLAW_WEBHOOK_STREAM) and apply it to all three run sites. ChatStream returns the fully assembled response, so the payload returned to the caller is unchanged. Set to false to restore non-streaming.
25 lines
471 B
Go
25 lines
471 B
Go
package webhooks
|
|
|
|
import "testing"
|
|
|
|
func TestResolveStream(t *testing.T) {
|
|
tr := true
|
|
fa := false
|
|
cases := []struct {
|
|
name string
|
|
in *bool
|
|
want bool
|
|
}{
|
|
{"nil uses default (true)", nil, true},
|
|
{"explicit true", &tr, true},
|
|
{"explicit false", &fa, false},
|
|
}
|
|
for _, c := range cases {
|
|
t.Run(c.name, func(t *testing.T) {
|
|
if got := ResolveStream(c.in); got != c.want {
|
|
t.Fatalf("ResolveStream(%v) = %v, want %v", c.in, got, c.want)
|
|
}
|
|
})
|
|
}
|
|
}
|