Skip to content

Make provider setup append models instead of overwriting#9

Closed
luckeyfaraday wants to merge 1 commit into
mainfrom
setup-appends-models
Closed

Make provider setup append models instead of overwriting#9
luckeyfaraday wants to merge 1 commit into
mainfrom
setup-appends-models

Conversation

@luckeyfaraday

Copy link
Copy Markdown
Owner

Problem

codex-shim setup <provider> wrote a single-model payload and overwrote the provider settings file. Running setup again to configure a second model silently dropped the first, so only the most recently set-up model appeared in the picker.

This bit a real session: setting up xiaomi/mimo-v2.5 overwrote a previously configured z-ai/glm-5.2 in openrouter-models.json. Because the shim reloads that file per request, the still-running GLM Codex session immediately started failing with 404 Unknown model slug/model: z-ai-glm-5-2 from the same shim that had been serving it.

Change

setup now merges the entered model into the existing rows, keyed by model id:

  • a new model id is appended — every configured model keeps appearing in the picker;
  • an existing model id updates that row in place — still idempotent, Enter-to-keep behavior preserved.

Existing rows are read as raw JSON (not via ModelSettings) so unknown / camelCase fields (extra_headers, no_image_support, etc.) on other models survive the rewrite untouched.

Tests

  • test_provider_setup_appends_new_model — two setups → both models present, in order.
  • test_provider_setup_updates_existing_model_in_place — same id twice → one row, fields updated.
  • test_provider_setup_preserves_unknown_fields_on_other_models — appending leaves another model's extra_headers/no_image_support intact.

Full suite: 45 passed (with pytest-asyncio installed).

Docs

README provider-workflow section updated to describe add-vs-update and how to remove a model.

🤖 Generated with Claude Code

`codex-shim setup <provider>` previously wrote a single-model payload,
discarding any models already configured in the provider settings file.
Re-running setup to add a model silently dropped the previous one, so only
the most recently configured model appeared in the picker (and in-flight
sessions on the dropped slug started 404ing once the shim reloaded the file).

Setup now merges the entered model into the existing rows, keyed by model id:
a new id is appended so every configured model keeps appearing, and an
existing id updates that row in place (still idempotent). Existing rows are
read raw so unknown/camelCase fields (extra_headers, no_image_support, etc.)
survive the rewrite untouched.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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