mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-15 00:17:27 +00:00
fix(providers): skip temperature for base gpt-5 and gpt-5-chat models (#1555)
OpenAI rejects non-default temperature on gpt-5 / gpt-5-chat with
HTTP 400 ("Unsupported value: 'temperature' does not support 0.7
with this model. Only the default (1) value is supported.").
skipTemp in buildRequestBody only covered gpt-5-mini / gpt-5-nano and
the o-series, so base gpt-5 and gpt-5-chat fell through and received
config.DefaultTemperature (0.7). On channel integrations the inbound
error is suppressed, leaving the agent silently dead.
The gpt-5.X flagship variants (gpt-5.1, gpt-5.4, gpt-5.5) keep their
temperature — only the base gpt-5 and gpt-5-chat aliases are locked
to the default.
Regression cases added for gpt-5, gpt-5-chat, gpt-5-chat-latest and
provider-prefixed forms; gpt-5 moved to the locked list in
TestBuildRequestBody_TemperatureKeptForNonReasoningModels per the
maintainer triage on #1460.
Fixes #1460
This commit is contained in:
1 parent
0e3eb57317
commit
0fef6ff596
2 files changed
+13
-3
No files matched your search
@@ -265,8 +265,14 @@ func (p *OpenAIProvider) buildRequestBody(model string, req ChatRequest, stream
|
||||
// Certain model families don't support custom temperature (locked to default).
|
||||
// This is a model-level constraint, not provider-specific — applies to both OpenAI and Azure.
|
||||
// Note: gpt-5.X flagship models (gpt-5.1, gpt-5.4, gpt-5.5) DO support temperature;
|
||||
// only the mini/nano reasoning variants reject it.
|
||||
skipTemp := strings.HasPrefix(capabilityModel, "gpt-5-mini") || strings.HasPrefix(capabilityModel, "gpt-5-nano") || strings.HasPrefix(capabilityModel, "o1") || strings.HasPrefix(capabilityModel, "o3") || strings.HasPrefix(capabilityModel, "o4")
|
||||
// the locked ones are the base gpt-5, gpt-5-chat, and the mini/nano reasoning variants.
|
||||
skipTemp := capabilityModel == "gpt-5" ||
|
||||
strings.HasPrefix(capabilityModel, "gpt-5-chat") ||
|
||||
strings.HasPrefix(capabilityModel, "gpt-5-mini") ||
|
||||
strings.HasPrefix(capabilityModel, "gpt-5-nano") ||
|
||||
strings.HasPrefix(capabilityModel, "o1") ||
|
||||
strings.HasPrefix(capabilityModel, "o3") ||
|
||||
strings.HasPrefix(capabilityModel, "o4")
|
||||
// Kimi Coding rejects any temperature override — `invalid temperature: only
|
||||
// 1 is allowed for this model`. Skip sending so the upstream applies its
|
||||
// own default (1). Matches the model-locked behavior of o1/o3/o4.
|
||||
|
||||
@@ -59,6 +59,9 @@ func TestBuildRequestBody_TemperatureSkippedForReasoningModels(t *testing.T) {
|
||||
// These model families don't support custom temperature (locked to default).
|
||||
// This is a model-level constraint, not provider-specific.
|
||||
models := []string{
|
||||
"gpt-5",
|
||||
"gpt-5-chat",
|
||||
"gpt-5-chat-latest",
|
||||
"gpt-5-mini",
|
||||
"gpt-5-mini-2025-01",
|
||||
"gpt-5-nano",
|
||||
@@ -68,6 +71,8 @@ func TestBuildRequestBody_TemperatureSkippedForReasoningModels(t *testing.T) {
|
||||
"o3",
|
||||
"o3-mini",
|
||||
"o4-mini",
|
||||
"openai/gpt-5",
|
||||
"openai/gpt-5-chat-latest",
|
||||
"openai/gpt-5-mini",
|
||||
"openai/o3-mini",
|
||||
}
|
||||
@@ -96,7 +101,6 @@ func TestBuildRequestBody_TemperatureKeptForNonReasoningModels(t *testing.T) {
|
||||
"gpt-4",
|
||||
"gpt-4o",
|
||||
"gpt-4-turbo",
|
||||
"gpt-5",
|
||||
"gpt-5.1",
|
||||
"gpt-5.4",
|
||||
"openai/gpt-5.4",
|
||||
|
||||
Reference in new issue
Block a user