Skip to content

fix(models): stop auto-populating fallbacks on every save#191

Closed
lizheng31 wants to merge 1 commit intoqingchencloud:mainfrom
lizheng31:main
Closed

fix(models): stop auto-populating fallbacks on every save#191
lizheng31 wants to merge 1 commit intoqingchencloud:mainfrom
lizheng31:main

Conversation

@lizheng31
Copy link
Copy Markdown

Summary applyDefaultModel() currently overwrites agents.defaults.model.fallbacks with ALL non-primary models on every save (add/edit/delete/sort/set-primary on the models page). As the model list grows, this creates an ever-expanding fallback chain that causes frequent failover stalls. ## What changed applyDefaultModel(state) now only syncs defaults.model.primary on every save. The fallbacks and defaults.models fields are only initialized when they are empty (first install scenario), not blindly overwritten. This preserves user-curated fallback chains while keeping the primary-model validation logic intact. ## Behavior | Scenario | Before | After | |----------|--------|-------| | Every save on models page | Fallback = ALL non-primary models | Fallback unchanged | | First install (empty fallback) | Initializes with all models | Initializes with all models | | Primary model deleted | Auto-switches to first model | Auto-switches | ## Cross-platform note This fix touches only src/pages/models.js, the React web frontend. It applies equally to Windows, macOS, and Linux deployments. Fixes #190

applyDefaultModel() now only syncs the primary model.
fallbacks and defaults.models are only initialized when empty
(first install), not overwritten on every save.

This prevents the curated fallback chain from being replaced
with ALL non-primary models on every models-page action,
which was causing frequent failover stalls/hangs.

Fixes: qingchencloud#190
@1186258278
Copy link
Copy Markdown
Contributor

感谢提交!这个问题确实存在,修复思路也是对的。不过我在审查时发现 PR 中 defaults.models 被误改成了 defaults.model.models(字段路径不同,前者是 �gents.defaults.models,后者会写到 �gents.defaults.model.models),会导致 models map 写到错误位置。

我已经基于你的思路在 main 上提交了修正版本(699cf1c),保留了正确的字段路径。核心逻辑与你的 PR 一致:只同步 primary,fallbacks 和 models 仅在为空时初始化。

Closes #190

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.

Models page auto-populates all non-primary models into fallbacks on every save

2 participants