Skip to content

[BUG] 手动恢复的免费模型会被下一次自动探测覆盖,且缺少手动/自动切换 #56

Closed

Description

@cheerc

Problem

After restoring a free model via WebUI ("恢复启用", POST /api/models/restore), the model shows manually_enabled and works, but the next hourly automatic probe overwrites that state. AvailabilityStore.Record() only guards on Generation, so a new probe round with the current generation unconditionally rewrites Disabled/Reason. Models that succeed on retry therefore get pulled again one hour after a manual restore. There is also no UI switch to choose manual vs automatic control — only a one-way restore button (disabled while the model is enabled).

Two related defects in the same path:

  • RestoreModel dereferences m.current.Load() without a nil check, so an admin call during startup / config-reload window can panic.
  • An inconclusive recheck (timeout / transport error) of a still-disabled model resets NextCheck to 1h and overwrites the disable reason, shrinking the intended 24h backoff and losing the disable evidence.

Evidence

  • internal/models/availability.go: Restore() sets Reason="manually_enabled", NextCheck=now+1h; Record() (called from internal/gateway/availability.go checkFreeModels) rewrites Disabled/Reason/NextCheck on generation match with no manual-state branch.
  • internal/gateway/availability.go: checkFreeModels probes every non-manual due model hourly; RestoreModel does m.current.Load().availability... with no nil guard.
  • webui/app.js loadAvailability(): only a "恢复启用" button, disabled = !item.disabled; no toggle back to automatic.
  • Runtime observation: availability file showed disabled:true, reason:http_401 across models while the same models succeed on manual retry.

Scope

  • internal/models/availability.go (Availability record, Restore / Record)
  • internal/gateway/availability.go (checkFreeModels, RestoreModel)
  • internal/admin/* + webui/app.js, webui/index.html (manual/auto control API + toggle)

Expected Outcome

  • A manually restored model stays enabled and is not overwritten by later automatic probe results, until the operator explicitly switches it back to automatic.
  • WebUI offers a per-model manual/automatic toggle with the control mode visible.
  • Admin model endpoints handle "runtime not loaded" without panicking; inconclusive rechecks of disabled models preserve the 24h backoff and original disable reason.

Related

Activity

  1. added 2 commits that reference this issue on Oct 8, 2026
    df56703
    1e2702f
  2. jasonxu114514 commented on Oct 8, 2026

    @jasonxu114514
    Owner

    已通过 #57 合入 main,提交 1e2702f。手动恢复现在会持久化为手动模式,后续探测和在途结果不会覆盖;可在 WebUI 切回自动探测。

    审查时补充修复了到期复测不确定后 NextCheck 仍过期、造成每分钟重复探测的问题,并确保重复切换到同一模式不会清除禁用证据。已禁用模型遇到临时错误继续按 24 小时复测,已启用模型按 1 小时复测。

    本地回归验证通过,PR 和合并后主分支的五项 Checks 均通过。最终提交不含测试文件。此修复已进入 main,当前发布版本仍为 v1.3.7。

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions