Merge pull request #151 from qiaoborui/codex/fix-openai-oauth-authorize-url

fix(auth): align OpenAI OAuth browser login URL
This commit is contained in:
Meng Zhuo
2026-02-15 09:27:19 +08:00
committed by GitHub
4 changed files with 79 additions and 21 deletions

View File

@@ -18,6 +18,8 @@ type CodexProvider struct {
tokenSource func() (string, string, error)
}
const defaultCodexInstructions = "You are Codex, a coding assistant."
func NewCodexProvider(token, accountID string) *CodexProvider {
opts := []option.RequestOption{
option.WithBaseURL("https://chatgpt.com/backend-api/codex"),
@@ -138,6 +140,9 @@ func buildCodexParams(messages []Message, tools []ToolDefinition, model string,
if instructions != "" {
params.Instructions = openai.Opt(instructions)
} else {
// ChatGPT Codex backend requires instructions to be present.
params.Instructions = openai.Opt(defaultCodexInstructions)
}
if maxTokens, ok := options["max_tokens"].(int); ok {

View File

@@ -21,6 +21,12 @@ func TestBuildCodexParams_BasicMessage(t *testing.T) {
if params.Model != "gpt-4o" {
t.Errorf("Model = %q, want %q", params.Model, "gpt-4o")
}
if !params.Instructions.Valid() {
t.Fatal("Instructions should be set")
}
if params.Instructions.Or("") != defaultCodexInstructions {
t.Errorf("Instructions = %q, want %q", params.Instructions.Or(""), defaultCodexInstructions)
}
}
func TestBuildCodexParams_SystemAsInstructions(t *testing.T) {