Skip to content

fix(providers): stop resurrecting models the endpoint no longer serves - #1277

Closed
yexisu wants to merge 3 commits into
vastsa:mainfrom
yexisu:fix/provider-live-model-list
Closed

yexisu wants to merge 3 commits into
vastsa:mainfrom
yexisu:fix/provider-live-model-list

Conversation

@yexisu

@yexisu yexisu commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #1257

Problem

When a custom OpenAI-compatible gateway (e.g. GPT-Load) revoked model entitlements from a key, refreshing the model list in PI-Desktop never shrank the list: models the upstream no longer serves kept appearing.

Root cause

The providersListModels live-discovery branch asked the endpoint first (correct), then passed the result through withConfiguredBindings, which re-added every stored model binding the endpoint had just dropped. The dead ids were therefore resurrected on every refresh, and only rows the endpoint actually served were cached, so the visible list and the cache disagreed.

Fix

The live branch now returns exactly what the endpoint served. Catalog and offline fallback branches keep configured bindings so offline editing stays usable, and the settings form continues to read stored bindings from provider.models directly.

Validation

  • New source-contract regression test in model-discovery-precedence.test.mjs pins that the live branch no longer re-adds configured bindings
  • node --test on model-discovery-precedence, model-cache, provider-model-list-scope, todo-recovery: 17/17 pass
  • git merge-base --is-ancestor origin/main HEAD verified before push

@vastsa

vastsa commented Oct 1, 2026

Copy link
Copy Markdown
Owner

审核结论:问题真实,但当前修复不能合入。

GitHub JS 门禁失败的具体回归是:apps/desktop/test/model-advanced-capabilities.test.mjs 仍失败(expected 3+ union sites, saw 2)。这不是单纯断言过时:该测试保护设置页在 live discovery 不再返回某个已配置模型时,仍能读取其 published record/capabilities。当前把 live 返回改成裸 models 后,这个配置模型从返回列表消失,设置页能力状态会丢失。

需要把两个需求拆开:live discovery/cache 不应把失效模型当作 endpoint-served 模型缓存或展示;但配置模型的 published record 仍必须在设置编辑路径可用。请保留/恢复独立的 configured-record enrichment,或让设置页从明确的配置模型数据源读取并补充对应回归测试,再重新跑完整 JS 门禁。当前 PR 还有 Head contains latest base 失败,因此暂不合入。

yexisu added 2 commits October 2, 2026 13:40
A live discovery answer replaced the visible list with the endpoint's
own models, then immediately re-added every stored model binding. When
an upstream gateway revoked a model from the key, the refresh kept
showing the dead entry, so the list never shrank without re-adding the
whole channel.

The live branch now returns exactly what the endpoint served; catalog
and offline fallbacks keep configured bindings so editing stays usable.
Pinned by a source-contract regression test alongside the existing
discovery-precedence suite.
The maintainer review found the wholesale live return dropped configured
bindings the endpoint no longer serves, so the settings panel lost their
published capabilities. The resurrection in vastsa#1257 is a persistence
concern — the durable cache already narrows to served rows via
forget_missing_discovered_models — so the live return unions configured
bindings again while caching only what the endpoint served. Source-slice
tests pin both halves.
@yexisu
yexisu force-pushed the fix/provider-live-model-list branch from 2d799a7 to 01fa02d Compare October 2, 2026 05:40
@yexisu

yexisu commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

感谢复核,已按「拆开两个需求」重做(01fa02d53,分支已 rebase 到最新 main):

  1. 恢复 live 分支的 configured-record enrichment:providers.listModels 的 live 返回重新 union withConfiguredBindings(models),设置面板对已配置模型的 published capabilities 回读不再丢失(model-advanced-capabilities 的 union-site 断言恢复通过)。
  2. 复活问题归位到持久化层:核对后确认 cache_discovered_models 本身已正确收窄——只写 endpoint 返回的行,forget_missing_discovered_models 按 answer+configured 丢弃不再服务的 discovered 行(crates/host-core/src/providers/catalog.rs),user 行不受影响。live 返回值从不持久化,所以之前的「裸 models 返回」修不了 [Bug] 密钥里已经失效且删除的模型刷新后任在列表 #1257,只会破坏能力回读。
  3. 源码切片测试钉住两半:live 分支必须 union,且 cacheForCurrentProvider(models) 在 union 之前、只见到 endpoint 实际返回的行。

验证:node --test model-discovery-precedence.test.mjs model-advanced-capabilities.test.mjs — 23/23 通过;分支含最新 main(merge-base --is-ancestor 通过)。Rust 侧无改动,本机无 cargo,cache_discovered_models 行为由既有 host-core 测试覆盖。

@vastsa

vastsa commented Oct 2, 2026

Copy link
Copy Markdown
Owner

复核了同步到最新 main 的版本:当前 diff 已不再修改运行时行为,只增加 provider-ipc 的 source 文本断言和注释;实际根因修复已在 main 的现有路径中(live discovery 的缓存先只写 endpoint 返回行,设置页再用 source=user 的配置行补能力信息,服务可选列表过滤这些 user 行;host-core 缓存只清理 stale discovered 行)。因此这条 PR 现在是 test-only 回归覆盖,不是独立修复根因的 landing candidate。按仓库当前临时 PR 类型策略,外部 test-only PR 不合入;问题本身已由 main 修复,我会关闭这条重复 PR,不另建替代 PR。

@vastsa vastsa closed this Oct 2, 2026

This branch was previously deployed

1 inactive deployment
Preview — 8e6b05d8 Deployed Oct 2, 2026 by vercel[bot]
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.

[Bug] 密钥里已经失效且删除的模型刷新后任在列表

2 participants