Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/internal/servicemodel/prober_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ func TestProbeServiceUsesConnectedCodexAccountAndRejectsMalformedResponse(t *tes
}
prober := New(store, manager, nil)
models, err := prober.ProbeService(context.Background(), service, contract.ProtocolOpenAIModels)
if err != nil || strings.Join(models, ",") != "gpt-6-astra,gpt-a,gpt-z" {
if err != nil || strings.Join(models, ",") != "codex-auto-review,gpt-6-astra,gpt-a,gpt-z" {
t.Fatalf("models=%v err=%v", models, err)
}
responseBody = `{"models":[]}`
empty, err := prober.ProbeService(context.Background(), service, contract.ProtocolOpenAIModels)
if err != nil || len(empty) != 0 {
if err != nil || strings.Join(empty, ",") != "codex-auto-review" {
t.Fatalf("empty Codex catalog = %v err=%v", empty, err)
}
responseBody = `{}`
Expand Down
2 changes: 1 addition & 1 deletion core/internal/subscription/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestConnectedAccountModelsAndResponsesPath(t *testing.T) {
if err != nil {
t.Fatalf("ListModels() = %v", err)
}
if len(models.Data) != 1 || models.Data[0].ID != "gpt-5" {
if len(models.Data) != 2 || models.Data[0].ID != "gpt-5" || models.Data[1].ID != "codex-auto-review" {
t.Fatalf("models = %#v", models)
}
body, status, err := manager.Provider().ProbeNonStreamingResponse(context.Background(), liveTokens, "gpt-5")
Expand Down
21 changes: 17 additions & 4 deletions core/internal/subscription/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,26 @@ func DecodeCodexModels(body []byte) (ModelList, error) {
if envelope == nil {
return ModelList{}, fmt.Errorf("decode codex models: empty object")
}
var list ModelList
var err error
if raw, ok := envelope["models"]; ok {
return decodeOfficialCodexModels(raw)
list, err = decodeOfficialCodexModels(raw)
} else if raw, ok := envelope["data"]; ok {
list, err = decodeOpenAICompatibleModels(raw)
} else {
return ModelList{}, fmt.Errorf("decode codex models: missing models or data")
}
if raw, ok := envelope["data"]; ok {
return decodeOpenAICompatibleModels(raw)
if err != nil {
return ModelList{}, err
}
return ModelList{}, fmt.Errorf("decode codex models: missing models or data")
// Codex's auto-review model may be omitted or hidden in the upstream catalog.
for _, model := range list.Data {
if model.ID == "codex-auto-review" {
return list, nil
}
}
list.Data = append(list.Data, ModelRecord{ID: "codex-auto-review", Object: "model"})
return list, nil
}

func decodeOfficialCodexModels(raw json.RawMessage) (ModelList, error) {
Expand Down
8 changes: 4 additions & 4 deletions core/internal/subscription/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,24 @@ func TestDecodeCodexModelsOfficialAndCompatibleEnvelopes(t *testing.T) {
if err != nil {
t.Fatalf("official DecodeCodexModels() = %v", err)
}
if got, want := modelIDs(official), "gpt-5,gpt-5-codex,gpt-4.1"; got != want {
if got, want := modelIDs(official), "gpt-5,gpt-5-codex,gpt-4.1,codex-auto-review"; got != want {
t.Fatalf("official IDs = %q, want %q", got, want)
}

compatible, err := DecodeCodexModels([]byte(`{"object":"list","data":[{"id":"gpt-z"},{"id":"gpt-a"},{"id":""}]}`))
if err != nil {
t.Fatalf("compatible DecodeCodexModels() = %v", err)
}
if got, want := modelIDs(compatible), "gpt-z,gpt-a"; got != want {
if got, want := modelIDs(compatible), "gpt-z,gpt-a,codex-auto-review"; got != want {
t.Fatalf("compatible IDs = %q, want %q", got, want)
}

emptyOfficial, err := DecodeCodexModels([]byte(`{"models":[]}`))
if err != nil || emptyOfficial.Data == nil || len(emptyOfficial.Data) != 0 {
if err != nil || modelIDs(emptyOfficial) != "codex-auto-review" {
t.Fatalf("empty official = %#v err=%v", emptyOfficial, err)
}
emptyCompatible, err := DecodeCodexModels([]byte(`{"data":[]}`))
if err != nil || emptyCompatible.Data == nil || len(emptyCompatible.Data) != 0 {
if err != nil || modelIDs(emptyCompatible) != "codex-auto-review" {
t.Fatalf("empty compatible = %#v err=%v", emptyCompatible, err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/internal/subscription/provider_compression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestProviderReadsCompressedCatalogAndNormalizesResponseHeaders(t *testing.T
provider := NewCodexProvider(accountauth.OAuthConfig{APIBaseURL: upstream.URL, HTTPClient: client})
tokens := accountauth.AccountTokens{AccessToken: "test-token"}
models, err := provider.ListModels(context.Background(), tokens)
if err != nil || len(models.Data) != 1 || models.Data[0].ID != "test-model" {
if err != nil || modelIDs(models) != "test-model,codex-auto-review" {
t.Fatalf("models = %#v, err = %v", models, err)
}
body, status, headers, err := provider.CreateResponse(context.Background(), tokens, []byte(`{"input":"test"}`))
Expand Down
Loading