Fix/model catalog cleanup#299
Open
YQYANG2233 wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR introduces a “prune stale remote models” action for the managed model catalog, and removes the implicit Codex image tool model from both API/UI listings while cleaning up legacy storage entries.
Changes:
- Add a new RPC/UI action to prune unedited remote catalog entries that no longer exist in the remote catalog.
- Stop injecting the Codex image tool model into model lists; filter/purge it from catalog storage and normalization paths.
- Add storage-level cleanup helpers to remove model-group and routing references when catalog entries are deleted.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/service/src/rpc_dispatch/mod.rs | Allowlists the new prune RPC method. |
| crates/service/src/rpc_dispatch/apikey.rs | Dispatches the new prune RPC method and returns filtered results. |
| crates/service/src/model_groups.rs | Triggers catalog read/purge and prunes default model-group entries during access checks. |
| crates/service/src/gateway/request/tests/local_models_tests.rs | Updates expectations now that the implicit image tool model is no longer injected. |
| crates/service/src/gateway/request/local_models.rs | Removes implicit image tool model augmentation from responses. |
| crates/service/src/apikey/apikey_models.rs | Implements prune RPC behavior; filters/purges Codex image tool model; expands deletion cleanup; adds tests. |
| crates/core/src/storage/model_sources.rs | Adds helper to delete model source routes for a “platform model”. |
| crates/core/src/storage/model_options.rs | Prunes default model-group entries before inserting default options. |
| crates/core/src/storage/model_groups.rs | Adds pruning and reference-deletion helpers for model groups. |
| apps/src/lib/i18n/messages/en.ts | Adds UI strings for the prune action and outcomes. |
| apps/src/lib/api/transport-web-commands.ts | Wires new web command to the prune RPC method. |
| apps/src/lib/api/account-client.ts | Adds client method to call prune RPC and normalize the result. |
| apps/src/hooks/useManagedModels.ts | Adds mutation + UX feedback for prune action; exposes pending state. |
| apps/src/app/models/page.tsx | Adds a destructive “prune stale remote models” button and disables actions while pending. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+194
to
+197
| "apikey/modelCatalogPruneStaleRemote" => super::value_or_error( | ||
| apikey_models::prune_stale_remote_managed_model_catalog() | ||
| .and_then(|catalog| filter_catalog_for_actor(actor, catalog)), | ||
| ), |
Comment on lines
+129
to
+143
| pub fn prune_default_model_group_models_not_in_catalog(&self) -> Result<()> { | ||
| self.conn.execute( | ||
| "DELETE FROM model_group_models | ||
| WHERE group_id IN (SELECT id FROM model_groups WHERE is_default = 1) | ||
| AND platform_model_slug NOT IN ( | ||
| SELECT slug | ||
| FROM model_catalog_models | ||
| WHERE scope = 'default' | ||
| AND COALESCE(supported_in_api, 1) = 1 | ||
| AND TRIM(slug) <> '' | ||
| )", | ||
| [], | ||
| )?; | ||
| Ok(()) | ||
| } |
Comment on lines
+334
to
+336
| storage | ||
| .prune_default_model_group_models_not_in_catalog() | ||
| .map_err(|err| format!("prune default model group failed: {err}"))?; |
| } | ||
|
|
||
| fn result_from_storage(storage: &Storage) -> Result<ModelGroupListResult, String> { | ||
| crate::apikey_models::read_managed_model_catalog_from_storage(storage)?; |
Comment on lines
+372
to
+390
| pub fn delete_model_source_routes_for_platform_model( | ||
| &self, | ||
| platform_model_slug: &str, | ||
| ) -> Result<()> { | ||
| let slug = normalize_text(platform_model_slug); | ||
| if slug.is_empty() { | ||
| return Ok(()); | ||
| } | ||
| self.conn.execute( | ||
| "DELETE FROM model_source_mappings | ||
| WHERE platform_model_slug = ?1 OR upstream_model = ?1", | ||
| params![&slug], | ||
| )?; | ||
| self.conn.execute( | ||
| "DELETE FROM model_source_models WHERE upstream_model = ?1", | ||
| params![&slug], | ||
| )?; | ||
| Ok(()) | ||
| } |
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.
变更摘要
gpt-image-2被当作普通模型目录项残留的问题,避免 Web 模型目录和/v1/models出现无法删除的内部图片工具模型。改动范围
/v1/models本地模型响应不再补入gpt-image-2。行为说明
gpt-image-2会被排除在普通平台模型目录之外。验证
cargo test -p codexmanager-service apikey::models::testscargo test -p codexmanager-service gateway::local_models::testscargo test -p codexmanager-service wallet_charge_uses_model_group_billing_model_overridecorepack pnpm test:runtimecorepack pnpm buildgit diff --check已知情况
corepack pnpm lint当前仍会因为仓库已有 React hook lint 问题失败,失败点不在本次修改范围内。风险与影响面
/v1/models输出。备注
model_catalog_json配置处理,不属于本 PR 范围。