Make provider setup append models instead of overwriting#9
Closed
luckeyfaraday wants to merge 1 commit into
Closed
Make provider setup append models instead of overwriting#9luckeyfaraday wants to merge 1 commit into
luckeyfaraday wants to merge 1 commit into
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.5overwrote a previously configuredz-ai/glm-5.2inopenrouter-models.json. Because the shim reloads that file per request, the still-running GLM Codex session immediately started failing with404 Unknown model slug/model: z-ai-glm-5-2from the same shim that had been serving it.Change
setupnow merges the entered model into the existing rows, keyed by model id: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'sextra_headers/no_image_supportintact.Full suite:
45 passed(withpytest-asyncioinstalled).Docs
README provider-workflow section updated to describe add-vs-update and how to remove a model.
🤖 Generated with Claude Code