From 0df6aba990ffd6eb42a14295249fefed1ac7adb5 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 17 Sep 2025 22:59:56 +0300 Subject: chore: commit uncommitted changes before version bump --- internal/llm/openai.go | 8 ++++++++ internal/llm/openai_request_test.go | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/internal/llm/openai.go b/internal/llm/openai.go index 8b00335..8a0d6d7 100644 --- a/internal/llm/openai.go +++ b/internal/llm/openai.go @@ -218,6 +218,14 @@ func buildOAChatRequest(o Options, messages []Message, defaultTemp *float64, str if len(o.Stop) > 0 { req.Stop = o.Stop } + // Enforce gpt-5 temperature constraints: only default (1.0) is supported. + if requiresMaxCompletionTokens(o.Model) { + if req.Temperature == nil || *req.Temperature != 1.0 { + t := 1.0 + req.Temperature = &t + logging.Logf("llm/openai ", "forcing temperature=1.0 for model=%s (gpt-5 constraint)", o.Model) + } + } return req } diff --git a/internal/llm/openai_request_test.go b/internal/llm/openai_request_test.go index f9925f9..001e3b7 100644 --- a/internal/llm/openai_request_test.go +++ b/internal/llm/openai_request_test.go @@ -22,6 +22,16 @@ func TestBuildOAChatRequest_MaxTokensKeyByModel(t *testing.T) { } } +func TestBuildOAChatRequest_TemperatureForcedForGpt5(t *testing.T) { + msgs := []Message{{Role: "user", Content: "hi"}} + // Explicit temp 0.2 → should be forced to 1.0 for gpt-5 + r := buildOAChatRequest(Options{Model: "gpt-5.0", Temperature: 0.2, MaxTokens: 50}, msgs, nil, false) + b, _ := json.Marshal(r) + if !contains(string(b), "\"temperature\":1") { + t.Fatalf("expected forced temperature 1.0 for gpt-5, got %s", string(b)) + } +} + func contains(s, sub string) bool { for i := 0; i+len(sub) <= len(s); i++ { if s[i:i+len(sub)] == sub { -- cgit v1.2.3