Repository navigation
Conversation
WenhuaXia
force-pushed
the
fix/auto-promote-first-model-to-default
branch
2 times, most recently
from
October 17, 2026 06:26
08bb40f to
720fe96
Compare
…ion tests for first-model auto-default (implementation upstreamed via PR AgentFlocks#54) 上游 origin/main 的 fix(models): set first configured model as default LLM (PR AgentFlocks#54) 已实现 _maybe_promote_first_model_to_default,且比本地原实现 多解析 legacy model 配置 + webui 创建后刷新默认模型。 本分支保留 8 个回归测试覆盖同一行为契约: 首个模型+凭据→设默认; inline key→设默认; 无凭据→不设; 第二个模型→不覆盖; 其它 provider 已有默认→不覆盖。 Upstream PR AgentFlocks#54 implements the same fix (plus legacy `model` resolution and a WebUI refresh after create). This branch now carries only the regression tests pinning the behavior contract.
WenhuaXia
force-pushed
the
fix/auto-promote-first-model-to-default
branch
from
October 19, 2026 10:09
720fe96 to
456bd84
Compare
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.
问题描述 / Bug Description
从模型管理页添加模型(非 onboarding 向导)后,provider 已配置、凭据已存、模型可用,但
default_models.llm为空。/api/onboarding/status要求「默认模型已设置 + 凭据可用」才返回completed=True,而 WebUI 在completed=False时每次登录都强制弹出初始化向导(前端 dismissed flag 被测试用例显式忽略)。结果:用户明明加了模型并可用,每次登录还是被弹初始化。
After adding a model from the model management page (not the onboarding wizard), the provider is configured and credentials exist, but
default_models.llmstays empty./api/onboarding/statusonly reportscompleted=Truewhen a default model is set AND credentials exist, and the WebUI force-opens the setup wizard on every login whencompleted=False.根因 / Root Cause
create_model(custom_provider.py)只 upsert 模型条目,从不调set_default_model。只有 onboarding/apply路径会设默认模型,而该路径此前被验证 bug 挡住(见 PR #779),用户只能跳过 onboarding 后手动加模型,陷入「有模型、无默认」的中间态。create_modelonly upserts the model entry and never callsset_default_model. Only the onboarding/applypath sets a default, and that path was previously blocked by the validation bug in PR #779 — users who skipped onboarding and added a model manually were left in a "model exists but no default" limbo.修复 / Fix
create_model新增_maybe_promote_first_model_to_default,当且仅当三个条件同时满足时自动把新模型设为默认 LLM:default_models.llm为空)设计取舍:
/api/onboarding/status的completed判定完全对齐;无凭据时不设,避免出现「设了默认但跑不通、status 仍 False」的矛盾态验证 / Verification
新增 5 个回归测试,覆盖全部条件组合:
测试运行:
真实环境验证:用户
openai-compatibleprovider +Qwen3.8-27B模型已配置,设默认后/api/onboarding/status返回completed=True,登录不再弹初始化。测试计划 / Test Plan
风险评估 / Risk Assessment
Low — 改动仅在
create_model内,且三重条件门控(首模型 ∧ 无默认 ∧ 有凭据),任何一条不满足都静默跳过。提升失败被 try/except 吞掉并记 warning,不影响 201 返回。不触及 onboarding/credential/默认模型管理端点的既有语义。关联 / Related