Skip to content

Commit 2286791

Browse files
fix(providers/openai): correct reasoning detection for deployment aliases and third-party model IDs (#88)
On Chat Completions a model ID that carried a reasoning marker together with gpt-3, gpt-4 or chatgpt- was treated as a non-reasoning model, so Azure deployments named like chatgpt-5 were sent max_tokens. The oss and computer-use markers also matched third-party model IDs, so they are now gpt-oss and a leading computer-use.
1 parent 32e0094 commit 2286791

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎providers/openai/reasoning.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
// reasoningModelPattern matches the model families known to reason: the
99
// o-series, gpt-oss, chat-latest, codex, computer-use, and gpt-5 onward. The
1010
// generation stays on a single digit so Azure's gpt-35-turbo is not caught.
11-
var reasoningModelPattern = regexp.MustCompile(`(?:^|[-.])(?:o[134]|oss|chat-latest)|gpt-[5-9]|codex-|computer-use`)
11+
var reasoningModelPattern = regexp.MustCompile(`(?:^|[-.])(?:o[134]|chat-latest)|gpt-oss|gpt-[5-9]|codex-|(?:^|/)computer-use`)
1212

1313
// nonReasoningModelPattern matches the OpenAI models known not to reason:
1414
// gpt-3, gpt-4, and the chat snapshots used in ChatGPT.
@@ -18,8 +18,7 @@ var nonReasoningModelPattern = regexp.MustCompile(`gpt-3|gpt-4|chatgpt-`)
1818
// Completions serves arbitrary OpenAI-compatible models, so only known
1919
// reasoning families qualify.
2020
func isReasoningModel(modelID string) bool {
21-
id := strings.ToLower(modelID)
22-
return reasoningModelPattern.MatchString(id) && !nonReasoningModelPattern.MatchString(id)
21+
return reasoningModelPattern.MatchString(strings.ToLower(modelID))
2322
}
2423

2524
// isResponsesReasoningModel reports whether a Responses API model reasons.

‎providers/openai/reasoning_test.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ func TestReasoningModelDetection(t *testing.T) {
2828
{"openai.gpt-oss-120b-1:0", true, true},
2929
{"codex-mini-latest", true, true},
3030
{"computer-use-preview", true, true},
31+
{"openai/computer-use-preview", true, true},
3132
{"gpt-5-chat-latest", true, true},
3233
{"gpt-5.1-chat", true, true},
3334
{"chat-latest", true, true},
3435
{"gpt-chat-latest", true, true},
3536

37+
// Deployment aliases that also carry a non-reasoning marker.
38+
{"chatgpt-5", true, false},
39+
{"gpt-4o-to-gpt-5", true, false},
40+
3641
{"chatgpt-4o-latest", false, false},
3742
{"gpt-4o", false, false},
3843
{"gpt-4.1-mini", false, false},
@@ -45,6 +50,8 @@ func TestReasoningModelDetection(t *testing.T) {
4550
{"gpt-10-turbo", false, true},
4651
{"some-custom-model", false, true},
4752
{"llama-3.3-70b", false, true},
53+
{"ByteDance-Seed/Seed-OSS-36B-Instruct", false, true},
54+
{"google/gemini-2.5-computer-use-preview-10-2025", false, true},
4855
}
4956

5057
for _, tt := range tests {

0 commit comments

Comments
 (0)