[Bug] 3.11.2 重启后自定义 provider 全部丢失:provider 家族引导重建 config.json 时未迁移 source:custom 的自定义 provider
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 22
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
提交前确认 · Pre-submission checklist
- 我已搜索过现有 issue,确认这不是重复(最接近的是 #272(已合并到 #268),但其根因是自定义 dataBaseDir 存储路径不一致;本 issue 是默认存储路径下、provider 家族引导重建 config.json 导致的丢失,根因环节不同)
- 我已阅读 CONTRIBUTING.md
问题类别 · Category
模型设置 / 切换 · Model config
涉及的 Agent 框架 · Agent framework
ZCode Agent(自研)
严重程度 · Severity
影响体验 · Major(配置数据静默丢失:自定义 provider 的 baseURL / API Key / 模型列表全部丢失,需手动重建;Key 无法找回时损失更大)
复现频率 · Reproducibility
仅一次 · Once(见下文"一次性"说明)
问题描述 · Description
Windows 桌面版 3.11.2。自定义 provider(UUID 形态 id、source: custom)仅持久化于 ~/.zcode/v2/config.json。2026-09-12 晚托盘退出并重启 ZCode 后,该文件被应用重写,只剩 6 个 builtin provider,所有自定义 provider(含 API Key)被静默丢弃,无任何提示或备份。
关键证据:
- 重写后的 builtin 条目均带
"source": "custom",且 setting.json 新增providerFamilyDomain/providerFamilyDomainMigrated/modelProviderFamilyModes/modelProviderFamilySelectedKeys字段——指向 provider 家族引导/迁移逻辑重建 provider 注册表时,未迁移非家族 ID 的 custom provider。 - 版本全天为 3.11.2 未变化(auto-update 日志:
already up to date (local=3.11.2, remote=3.11.2)),排除升级触发。 - 当晚 20:42 重启后自定义 provider 仍在正常工作(日志中百炼 anthropic endpoint 作为 runtimeModel 加载),丢失发生在其后一次重启的 20:53–20:55 config.json 重写。
- 手工恢复配置后,应用随后多次重写 config.json 均完整保留自定义 provider——说明清洗是一次性迁移行为,迁移通过后不再复发。
复现步骤 · Steps to reproduce
- 在 3.11.2 配置若干自定义 provider(config.json 中
source: custom、UUID 形态 id),正常使用多日 - 托盘退出 ZCode,重新启动(期间触发 provider 家族引导/迁移)
- 打开模型设置:自定义 provider 全部消失;检查
~/.zcode/v2/config.json仅剩 builtin provider
(触发条件与家族引导/迁移的精确对应关系未能从日志定位到具体代码行,但重写者为应用自身,时间窗口与写盘行为吻合。)
期望表现 · Expected behavior
- 迁移/重建 provider 注册表时保留所有
source: custom的自定义 provider - 若确需清洗配置,先自动落一份
config.json.bak并提示用户
实际表现 · Actual behavior
- config.json 被重写为仅含 builtin provider,自定义 provider 及其 API Key 静默丢失,无提示、无备份
- 应用内无法找回;第三方网关类 Key 只能手动重建
ZCode 版本 · ZCode version
3.11.2(Windows 桌面版)
设备 / 系统 / 浏览器 · Device / OS / Browser
Windows 10 Pro 22H2 (19045) x64
截图 / 录屏 / 日志 · Screenshots / Recordings / Logs
日志时间线(~/.zcode/v2/logs/2026-09-12.log,日志中 Key 已由应用脱敏):
[2026-09-12 20:38:31] [app-quit] explicit quit requested (tray-quit)
[2026-09-12 20:38:37] [arms] electron initialized env=prod version=3.11.2
(setting.json 随后写入 providerFamilyDomain=bigmodel / providerFamilyDomainMigrated=true)
[2026-09-12 20:42:11] [zcode-agent-service] 开始请求 workspace/readState
{"hasRuntimeModel":true,"runtimeModel":{"apiFormat":"anthropic-messages",
"baseURL":"https://llm-***.cn-beijing.maas.aliyuncs.com/apps/anthropic","kind":"anthropic",...}}
← 自定义 provider 仍在正常工作
[2026-09-12 20:43:12] [arms] electron initialized env=prod version=3.11.2
[2026-09-12 20:53-20:55] config.json / setting.json 被重写;重写后 config.json 仅含 6 个
builtin provider(均带 "source":"custom"),多个 UUID 形态的自定义 provider 全部消失
补充说明(恢复路径,供研发参考):旧配置可从本机 ~/.zcode/cli/db/db.sqlite(任务索引保存了历史会话完整读取 config.json 的工具结果)与系统卷影副本部分重建,代价较高;若应用在重写前自动备份一份旧 config.json,用户即可完全免于手工恢复。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the provider-family migration or registry-rebuild path that rewrites ~/.zcode/v2/config.json, using the 20:53–20:55 entries in ~/.zcode/v2/logs/2026-09-12.log as the timeline. Compare the rebuilt entries with setting.json fields such as providerFamilyDomainMigrated and modelProviderFamilyModes. Done means source: custom providers, including UUID IDs, survive migration; if cleanup remains necessary, config.json is backed up first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100