Skip to content

Persisted connection catalogs keep model ids that the snapshot has retired #3354

Closed

Description

@Astro-Han

When a models.dev refresh removes a model id from a provider's fallback list, existing users keep it. ensureConnection (packages/runtime-host/src/server/bootstrap-runtime-policy.ts) returns an existing connection unchanged, so enabledModelIds is never reconciled against the current registry. A persisted default target stays valid while the old id is still enabled (packages/storage/src/runtime-policy/connection-catalog-document.ts), and Host admission trusts the persisted models[] row (packages/runtime-host/src/server/connection-model-admission.ts). The id is still shown as available and default-capable, and still admitted for execution, after the provider has retired it.

Providers with modelDiscovery: { kind: 'protocol' } self-heal on the next successful discovery. Two cases do not:

  • opencode-free is { kind: 'fallback' } — its own reason string states the anonymous endpoint has no model-list contract, so no discovery pass ever repairs the state.
  • google preserves the old catalog when discovery fails.

Why this is not tied to one refresh

This is standing behaviour, not a regression. #2050 removed hy3-free from the same OpenCode Free list for the same reason — an upstream deprecation — and touched no persistence: git show 41a983804 --name-only matches zero files under packages/storage/ or packages/runtime-host/. There is no model-catalog migration or tombstone mechanism; the tombstones in sqlite-session-metadata-store.ts serve session metadata only.

Reverting a refresh does not fix it either: the ids return to the fallback lists but remain retired upstream, so a persisted default still fails at call time.

Scope

A targeted upgrade migration that, for providers without a self-healing discovery contract, removes retired ids from persisted inventories and enabled sets and clears or repairs a matching default target, with base-state upgrade tests.

Found during review of #3324 by @hqhq1025.

Activity

  1. added
    bug
    on Aug 20, 2026
  2. added
    good first issue
    help wanted
    on Aug 22, 2026
  3. mikemikimike commented on Aug 22, 2026

    @mikemikimike
    Contributor

    我对本 PR 做了一次补充自检,结论如下:\n\n1. 原始 Issue 的问题有意义且可复现:Runtime Host 启动时,已退休的 OpenCode Free model id 仍可能保留在 enabledModelIds/models/defaultTarget 中,导致 catalog 状态与可用模型不一致。修复目标是一次性、幂等地协调这三处状态,并保留用户仍在使用的非退休模型。\n2. 本 PR 已覆盖退休模型清理、默认目标修复和用户模型保留,测试通过前因 Windows TypeScript 7 native compiler EBUSY 被环境阻断,不能把它表述为完整验证。建议 CI 重新运行同一 focused test。\n3. 额外风险已考虑:重复启动不能重复破坏状态;没有退休模型时不应写入无关变更;未命中的 provider-discovered model 不应被迁移逻辑改写。\n4. 原子性/一致性方面,enabledModelIds、models、defaultTarget 必须在同一次 catalog write 中更新,避免中间状态被读取;迁移应保持幂等,不引入并发重试或额外生命周期变化。\n5. 当前回归测试方向正确,但 CI 仍需确认 Windows/Node 工具链下的实际执行结果;建议额外确认空 inventory、defaultTarget 指向已退休模型、重复执行和用户模型与退休模型并存的场景。

  4. added a commit that references this issue on Aug 23, 2026
    4ee7be5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions