Skip to content

fix(provider): 注入网关模型列表到 Codex /model 并补全 metadata - #81

Merged
cursor[bot] merged 12 commits into
devfrom
cursor/provider-model-catalog-dd00
Aug 27, 2026
Merged

cursor[bot] merged 12 commits into
devfrom
cursor/provider-model-catalog-dd00

Conversation

@xjoker

@xjoker xjoker commented Aug 27, 2026 •

Copy link
Copy Markdown
Owner

Problem

Switching to a custom API provider with a slug Codex does not ship (for example glm-5.3-flash) started Codex with a missing-metadata warning and a 272k fallback window. Custom-provider launch also must not read or write the user's ~/.codex.

This branch is rebased/merged onto current dev (multi-model providers, TUI form, launch passthrough) and bumps the rolling-dev base to 20260827.2.0.

Change

  • Launch writes $CODEX_SWITCH_HOME/providers/<alias>/models.json as model_catalog_json.
  • Metadata comes from {base_url}/models, then a configurable fallback (default public OpenRouter, no provider key).
  • Codex child CODEX_HOME is $CODEX_SWITCH_HOME/providers/<alias>/codex-home. Nothing is copied from the user's $CODEX_HOME.
  • --metadata-fallback URL|PATH|none on provider add.

Tests

cargo clippy --all-targets -- -D warnings and cargo test --all passed locally after the merge.

Open in Web Open in Cursor 

Codex has no built-in metadata for slugs such as glm-5.3-flash, so a
custom provider launch warned and fell back to a 272k window. Launch now
writes a catalog next to provider.toml and passes model_catalog_json
unless the provider already set one.

Co-authored-by: lolitaupdate <[email protected]>
@xjoker
xjoker marked this pull request as ready for review August 27, 2026 03:56
Launch fills the generated catalog from GET {base_url}/models: small
lists replace the bundled picker wholesale, large catalogs stay limited
to --model/--models while still copying context windows and names.

Co-authored-by: lolitaupdate <[email protected]>
@cursor cursor Bot changed the title fix(provider): 自定义模型启动时提供 Codex catalog,消除 metadata 警告 fix(provider): 注入网关模型列表到 Codex /model 并补全 metadata Aug 27, 2026
cursoragent and others added 10 commits August 27, 2026 04:35
When the gateway /models call fails or omits a context window, fill
display names and windows from the public OpenRouter catalog. Keep the
provider slug, never forward the API key, and do not inject OpenRouter's
full list into /model.

Co-authored-by: lolitaupdate <[email protected]>
Per-provider --metadata-fallback (URL, local JSON, or none) wins over
CODEX_SWITCH_METADATA_FALLBACK / CODEX_SWITCH_OPENROUTER_MODELS_URL, then
the public OpenRouter list. Gateway /models stays first; fallback never
decides which slugs appear in Codex /model.

Co-authored-by: lolitaupdate <[email protected]>
Host equality skipped a same-IP mock (and would skip a same-host custom
catalog). Compare the gateway /models URL to the fallback source instead.

Co-authored-by: lolitaupdate <[email protected]>
--metadata-fallback added another String to the clap parse-once enum and
tripped clippy::large_enum_variant.

Co-authored-by: lolitaupdate <[email protected]>
Custom-provider launch now sets the child's CODEX_HOME to
providers/<alias>/codex-home. First launch may snapshot the user's
config.toml (MCP servers); auth.json and other Codex files stay put.

Co-authored-by: lolitaupdate <[email protected]>
The PATH probe used to execute `codex --version`, which writes helper
binaries into the caller's CODEX_HOME. Look up the binary on PATH instead
so a custom-provider launch does not touch the user's ~/.codex at all.

Co-authored-by: lolitaupdate <[email protected]>
Custom-provider launch already points Codex at
$CODEX_SWITCH_HOME/providers/<alias>/codex-home. Stop snapshotting the
user's config.toml from $CODEX_HOME so MCP and other settings are not
inherited from ~/.codex; Codex writes its own runtime files in our tree.

Co-authored-by: lolitaupdate <[email protected]>
Keep custom-provider catalog injection and `$CODEX_SWITCH_HOME/providers/<alias>/codex-home` on top of the multi-model provider, TUI form, and launch passthrough already on `dev`. Do not copy or write the user's `~/.codex`.

Co-authored-by: lolitaupdate <[email protected]>
Allocate today's second rolling-dev base so CI can inject 20260827.2.0-dev.

Co-authored-by: lolitaupdate <[email protected]>
@cursor
cursor Bot merged commit 153c305 into dev Aug 27, 2026
1 of 4 checks passed
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.

2 participants