Skip to content

fix(cliproxy): keep original model ids routable with aliases#4125

Open
daiaji wants to merge 6 commits into
router-for-me:devfrom
daiaji:fix/model-alias-original-routing
Open

fix(cliproxy): keep original model ids routable with aliases#4125
daiaji wants to merge 6 commits into
router-for-me:devfrom
daiaji:fix/model-alias-original-routing

Conversation

@daiaji

@daiaji daiaji commented Jul 7, 2026

Copy link
Copy Markdown

Summary

  • Register both configured aliases and their original upstream model IDs for config-backed model entries.
  • Keep original model IDs routable for codex-api-key and openai-compatibility providers when aliases are configured.
  • Add regression coverage for provider lookup through both alias and original model names.

Why

When a config model had an alias, only the alias was registered in the global model registry. Requests using the original upstream model ID failed at provider lookup with unknown provider for model before executor-level alias resolution could map name -> name.

Tests

  • go test ./sdk/cliproxy ./sdk/api/handlers -count=1 -timeout 120s
  • go build -o /tmp/opencode/cli-proxy-api-pr-test ./cmd/server

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

This pull request targeted main.

The base branch has been automatically changed to dev.

@github-actions github-actions Bot changed the base branch from main to dev July 7, 2026 05:42

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the model registration logic to ensure that both the original model name and its configured alias are registered and remain routable. It introduces a helper function appendModelInfoIfUnique to handle deduplication. A new test is added to verify this behavior for Codex and OpenAI compatibility configurations. Feedback was provided to optimize appendModelInfoIfUnique by avoiding unnecessary cloning of the ModelInfo struct, which can be modified and appended directly.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread sdk/cliproxy/service.go Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b42bc309b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread sdk/cliproxy/service.go Outdated
if modelID == "" {
return models
}
key := strings.ToLower(modelID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve case-distinct original model IDs

When a configured alias differs from the upstream name only by capitalization, this case-folded de-dupe (together with the EqualFold checks in the two builders) still registers only the alias. Provider lookup is an exact map lookup by the requested model ID, so Name: "gpt-5" with Alias: "GPT-5" leaves requests for the real upstream gpt-5 failing with unknown provider for model, even though this change is intended to keep original IDs routable.

Useful? React with 👍 / 👎.

daiaji and others added 2 commits July 7, 2026 13:49
appendModelInfoIfUnique receives freshly allocated ModelInfo values from its callers, so cloning the struct before appending is unnecessary.

Trim and assign the normalized ID directly on the provided value, then append it to the model list.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28f8f0acda

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread sdk/cliproxy/service.go Outdated
Comment on lines +2583 to +2585
if name != "" && alias != name {
nameInfo := &ModelInfo{
ID: name,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor exclusions for alias/name pairs

When an API-key config uses an alias and excludes that alias (the only registered ID before this change), registerModelsForAuth still runs applyExcludedModels on the expanded slice. This new branch adds the upstream name as another ID, so a config like models: [{name: "gpt-5", alias: "my-gpt"}] with excluded-models: ["my-gpt"] now registers gpt-5 and leaves the same credential selectable for the excluded upstream model. Please make exclusions apply to the whole alias/name pair or filter before adding the extra routable ID.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2a2cb295d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread sdk/cliproxy/service.go Outdated
Comment on lines +2636 to +2638
nameInfo := &ModelInfo{
ID: name,
Object: "model",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve static metadata for original IDs

When one API-key config aliases a built-in model while another credential for the same provider registers the normal catalog, this new original-ID entry can be the last RegisterClient writer for that provider/model. The registry stores a single ModelInfo per provider, so the minimal nameInfo replaces the static entry for e.g. gpt-5.4-mini, dropping context length/supported parameters and marking the built-in as user-defined in lookups/model listings. Build the original-ID entry from the static ModelInfo when it exists (or avoid overwriting it), rather than constructing a fresh minimal record.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9df43e970

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread sdk/cliproxy/service.go
if name == "" {
return nil
}
if info := registry.LookupStaticModelInfo(name); info != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve compat thinking on original IDs

Fresh issue in the static-metadata fix: when an OpenAI-compatible entry aliases a static native model (for example name: "gemini-2.5-pro", alias: "gemini-pro"), this branch copies the native static Thinking field and ignores the OpenAI-compatible thinking value passed in from buildOpenAICompatibilityConfigModels. The alias keeps level-based OpenAI-compatible reasoning, but the newly registered original ID is looked up with Gemini/Claude budget metadata, so direct requests such as gemini-2.5-pro(high) do not have the suffix applied through the OpenAI-compatible executor. Please overlay the provider/config Thinking on top of the static metadata for these original-ID entries.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant