From 22bf9018a790f20061531df1a8fd8503170a41b6 Mon Sep 17 00:00:00 2001 From: loveuer Date: Wed, 23 Sep 2026 17:13:57 +0800 Subject: [PATCH] fix(openai): preserve temperature for Responses requests --- pkg/providers/openai_compat/provider.go | 3 +++ pkg/providers/openai_compat/provider_test.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/providers/openai_compat/provider.go b/pkg/providers/openai_compat/provider.go index d96fc6fa..09b3ab83 100644 --- a/pkg/providers/openai_compat/provider.go +++ b/pkg/providers/openai_compat/provider.go @@ -504,6 +504,9 @@ func (p *Provider) buildResponsesRequestBody( if maxTokens, ok := common.AsInt(options["max_tokens"]); ok { requestBody["max_output_tokens"] = maxTokens } + if temperature, ok := common.AsFloat(options["temperature"]); ok { + requestBody["temperature"] = temperature + } if cacheKey, ok := options["prompt_cache_key"].(string); ok && cacheKey != "" && supportsPromptCacheKey(p.apiBase) { requestBody["prompt_cache_key"] = cacheKey diff --git a/pkg/providers/openai_compat/provider_test.go b/pkg/providers/openai_compat/provider_test.go index 36355dbf..b97ab1ed 100644 --- a/pkg/providers/openai_compat/provider_test.go +++ b/pkg/providers/openai_compat/provider_test.go @@ -94,8 +94,8 @@ func TestProviderChat_OpenAIUsesResponsesAPI(t *testing.T) { if requestBody["max_output_tokens"] != float64(256) { t.Fatalf("max_output_tokens = %v, want 256", requestBody["max_output_tokens"]) } - if _, ok := requestBody["temperature"]; ok { - t.Fatalf("temperature should be omitted from Responses request, got %v", requestBody["temperature"]) + if requestBody["temperature"] != 0.2 { + t.Fatalf("temperature = %v, want 0.2", requestBody["temperature"]) } if requestBody["prompt_cache_key"] != "agent-main" { t.Fatalf("prompt_cache_key = %v, want agent-main", requestBody["prompt_cache_key"])