fix: remove max_tokens

This commit is contained in:
zenix.huang 2026-02-16 12:49:11 +09:00 committed by Guoguo
parent e072c7ba69
commit cc38096933
2 changed files with 11 additions and 4 deletions

View file

@ -260,10 +260,6 @@ func buildCodexParams(messages []Message, tools []ToolDefinition, model string,
params.Instructions = openai.Opt(defaultCodexInstructions) params.Instructions = openai.Opt(defaultCodexInstructions)
} }
if maxTokens, ok := options["max_tokens"].(int); ok {
params.MaxOutputTokens = openai.Opt(int64(maxTokens))
}
if len(tools) > 0 { if len(tools) > 0 {
params.Tools = translateToolsForCodex(tools) params.Tools = translateToolsForCodex(tools)
} }

View file

@ -29,6 +29,9 @@ func TestBuildCodexParams_BasicMessage(t *testing.T) {
if params.Instructions.Or("") != defaultCodexInstructions { if params.Instructions.Or("") != defaultCodexInstructions {
t.Errorf("Instructions = %q, want %q", params.Instructions.Or(""), defaultCodexInstructions) t.Errorf("Instructions = %q, want %q", params.Instructions.Or(""), defaultCodexInstructions)
} }
if params.MaxOutputTokens.Valid() {
t.Fatalf("MaxOutputTokens should not be set for Codex backend")
}
} }
func TestBuildCodexParams_SystemAsInstructions(t *testing.T) { func TestBuildCodexParams_SystemAsInstructions(t *testing.T) {
@ -214,6 +217,10 @@ func TestCodexProvider_ChatRoundTrip(t *testing.T) {
http.Error(w, "stream must be true", http.StatusBadRequest) http.Error(w, "stream must be true", http.StatusBadRequest)
return return
} }
if _, ok := reqBody["max_output_tokens"]; ok {
http.Error(w, "max_output_tokens is not supported", http.StatusBadRequest)
return
}
resp := map[string]interface{}{ resp := map[string]interface{}{
"id": "resp_test", "id": "resp_test",
@ -293,6 +300,10 @@ func TestCodexProvider_ChatRoundTrip_TokenSourceFallbackAccountID(t *testing.T)
http.Error(w, "temperature is not supported", http.StatusBadRequest) http.Error(w, "temperature is not supported", http.StatusBadRequest)
return return
} }
if _, ok := reqBody["max_output_tokens"]; ok {
http.Error(w, "max_output_tokens is not supported", http.StatusBadRequest)
return
}
if reqBody["stream"] != true { if reqBody["stream"] != true {
http.Error(w, "stream must be true", http.StatusBadRequest) http.Error(w, "stream must be true", http.StatusBadRequest)
return return