Bound LLM completion responses (V-608)

The owner explicitly requested direct commits on master; --no-verify bypasses the branch-only workflow hook for that instruction.
This commit is contained in:
2026-08-13 01:58:28 +04:00
parent 56254a51fa
commit d7e8804db5
2 changed files with 31 additions and 1 deletions
+16
View File
@@ -91,3 +91,19 @@ func TestSetBaseURL(t *testing.T) {
t.Errorf("request after the swap went to %q; want B", hit)
}
}
func TestCompleteRejectsOversizeResponse(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(`{"choices":[{"message":{"content":"`))
_, _ = w.Write([]byte(strings.Repeat("x", int(MaxResponseBytes))))
_, _ = w.Write([]byte(`"}}]}`))
}))
defer srv.Close()
c := New(srv.URL, 5*time.Second)
_, err := c.Complete(context.Background(), Req{User: "x"})
if err == nil || !strings.Contains(err.Error(), "response exceeds") {
t.Fatalf("Complete oversize error = %v, want bounded-response error", err)
}
}