Skip to content

fix(chatbot): drop the CLI default model from the chat model picker - #1000

Open
Robert0622 wants to merge 12 commits into
mainfrom
fix/chatbot-drop-cli-default-model
Open

Robert0622 wants to merge 12 commits into
mainfrom
fix/chatbot-drop-cli-default-model

Conversation

@Robert0622

Copy link
Copy Markdown
Collaborator

What changed

Follow-up to #978. #978 stopped forcing the chat model back to the default, but the AI 对话 model picker still listed 「CLI 默认模型」 (default) first. A user with nothing remembered therefore still started on it.

Chat now drops the CLI default from its model list:

  • CodeBuddy list (GET /api/assistant/models): the default entry is filtered out in the chatbot. A new conversation starts on the remembered model, else on the first listed one.
  • Catalog of a CLI without a key (GET /api/assistant/models?executor=codex and others): the CLI default entry is dropped the same way.
  • Saved conversations on default: when opened, edited or regenerated, they move to the remembered or first listed model, like a new conversation. An old remembered default in localStorage falls back to the first listed model, as any retired model does.
  • default stays listed only when CodeBuddy has no other model to offer (for example a guest before discovery has run), or when the administrator limited the shared key to it, so chat keeps working in those cases.

The filtering lives in the chatbot (chatModelList and sessionModel in chatbot/src/useChat.js). GET /api/assistant/models and the backend are unchanged on purpose. The classic role, scheduler, clarification and SOP preview pickers read the same catalog, and there default means "follow the operator's default". Roles, schedules and executors pinned to default keep working, and the backend still accepts default from older clients.

Scope

  • Platform core / API / runner
  • Public adapter / deployment
  • Classic
  • Portable
  • Shared behavior contract
  • Installer / CLI
  • Documentation only

Compatibility

No API, schema or migration change. Only the chatbot model picker changes. Related: #876 (open) normalizes <cli>:default to an unset model on the backend. It does not conflict with this change: chat no longer sends default for those CLIs once their list has loaded.

Validation

cd chatbot && npx vitest run tests/hooks.test.jsx
  26 passed (4 of them fail on main: 2 updated, 2 new)
cd chatbot && npm test
  Test Files 56 passed (56), Tests 387 passed (387)
cd chatbot && npm run build
  built
python3 scripts/check-public.py
  Public content check passed

New tests in chatbot/tests/hooks.test.jsx:

  • chatModelList drops default. It keeps default when CodeBuddy offers nothing else, or when the shared key allows it.
  • A conversation saved on default opens and regenerates on the first listed model.

The updated tests now expect the first real model for a new chat and for the Codex catalog.

Not run: Go tests (no Go change), local/ scripts. bash scripts/scan-secrets.sh could not run in this sandbox: extracting gitleaks failed with Cannot change ownership ... Operation not permitted.

Safety

  • I did not include credentials, internal endpoints, production data, or organization-specific infrastructure.
  • I preserved user files and unrelated changes.
  • I updated generated Classic host bundles when applicable.
  • I documented third-party content and licensing changes when applicable.

roberttwang added 2 commits November 17, 2026 11:02
The chat model picker listed 「CLI 默认模型」 (default) first, so a new
conversation without a remembered model started on it. Chat now starts on
the remembered model, else the first listed one, and no longer offers the
CLI default for CodeBuddy or for the catalog of a CLI without a key.

A conversation saved on default moves to that model when opened, edited
or regenerated. default stays listed only when CodeBuddy has no other
model, or when the shared key is limited to it. The backend catalog and
the classic pickers are unchanged.

@Robert0622 Robert0622 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

默认模型选择会随请求变化。 b48effff 的 24 个聊天 hook 测试及模型目录既有用例均通过。我另外固定了两个同环境账号的缓存目录,清空显式默认配置,连续读取 256 次,实际选择为 model-a 222 次、model-b 34 次。该分支与 main@6a331fb5 另有 17 个冲突文件,包括模型目录和聊天选择器。

Comment thread internal/httpapi/assistant_models.go Resolved

@Robert0622 Robert0622 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审通过 · 1fd41104

真实 iOA CodeBuddy CLI 和模型 HTTP 接口返回 36 个可用模型。另一个账号的测试缓存中存在不同模型时,连续解析 256 次均选中当前账号列表的第一项,未出现其他账号的模型。也复测了没有缓存时的两个独立账号、已保存的个人模型、共享 Key、使用 Runner 登录的旧定时任务及其离线切换,以及报告模型与用量记录。最终提交上,聊天前端 453 项测试通过。使用真实 MySQL 和 Chromium 验证未配置 Key 时点击发送保留草稿、无会话写入,并能直接打开个人凭证配置。公开浏览器套件运行的 23 项均通过。

已核对本提交的差异和 GitHub 检查,当前没有发现阻塞合并的问题。

crispinhu27
crispinhu27 previously approved these changes Nov 21, 2026

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

初审 #1000(head 1fd4110,merge-base 5fadefc)。

审查范围:全部 67 个变更文件。后端:assistant_models.go(cliModelEntry 去 environment 字段、cachedCLIModels 改为按账号 key 查询)、engines/executor_models/catalog/assistant.go/domain/preview.go 等约 20 个文件;前端:chatbot/src/useChat.js、web/app/assistant-models.js 及 5 个 JS 文件;对应测试文件全部读取。

验证:internal/domain 测试通过;TestAssistantModelPickerOmitsCodeBuddyCLIDefault、TestCodeBuddyModelDiscoveryPerEnvironment、TestCodeBuddyImplicitModelStaysWithItsAccount(256 次迭代,两账号各自固定选第一个模型)、TestScheduledRunModel*、TestClarifyAllowedModel*、TestSOPReport*、TestNotification*、TestScheduleJobUsesSaversDefaultRunnerLogin 全部通过;chatbot hooks.test.jsx(52 个测试,含 PR 新增的 2 个用例)通过。baseline 对比确认新断言仅出现在 head。CI 全部通过。

核心改动正确性:sha256(environment + apiKey) 缓存 key 完全消除了同环境不同账号的顺序不确定性,解决了作者在 PR 中指出的 P2 问题。ChosenModel 兼容处理了所有 clarify/schedule/SOP report/Bot/preview build/runner login 路径。未发现确认问题。以上不代表代码没有其他缺陷。

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审结论:APPROVE(head 9dcb98aa,base main@42541ef)

本次变化:两个合并提交,PR 自身代码没有变化。净 diff 仍是 67 个文件,+432/−298,和上次批准的 1fd4110 相同。

  • 798f129(合入 main@edc27c0)
    • CHANGELOG.md:主线新增的 4 条 designer 条目保留,本 PR 的条目放在后面。
    • web/i18n-en.js:逐 key 对比,合并结果相对 main 只少 "CLI 默认模型"(本 PR 本来就要删它),主线新增的 13 个 key(designer、MCP 接入引导等)都在。
    • 其他文件都是自动合并。主线新增的代码没有引用本 PR 改过签名或语义的符号。
    • 新的 SopDesigner 直接读 /api/assistant/models。目录里已经没有 default,designer 的模型选择器会落到第一个模型,记住的旧 default 也会回落到第一个模型,和本 PR 的意图一致。
  • 9dcb98a(合入 main@42541ef,含 #1080):--remerge-diff 只在 web/app/sync-schedule.js 的 fillScheduleJobForm 有一处冲突。解决后同时保留了本 PR 的 assistantModel=job.assistantModel||firstModel() 和主线的 timeoutMinutes 回填。主线在 sync-schedule.js 的其余 3 处 timeoutMinutes 改动和 index.html 里的新输入框都在。

已执行的验证(隔离沙箱用户和隔离数据库,合成数据,不接触任何凭据)

  • chatbot 的 npm ci && npm test && npm run build:465 项全部通过(base 463 项,多出的 2 项是本 PR 新增)。两次合并都没有改 chatbot/。
  • webtest:在 798f129 上全量 219/219 通过;在 9dcb98a 上相关子集 40/40 通过,包括 sync-schedule、platform-admin、orchestrate-ai/build、sop-sandbox-selection、module-logic。
  • Go:go build ./... 和 go vet 通过;domain、repo、web 测试通过。internal/httpapi 只有两个浏览器环境用例失败,base 上同样失败。TestScheduledNativeUsageReproduction/codex_two_calls 偶发失败,-count=30 时 head 7 次、base 42541ef 4 次、edc27c0 7 次,属于主线已有的不稳定用例。
  • 运行验证(用本 head 构建的服务连隔离 MariaDB):
    • /api/assistant/models 没有 key 时返回 {"default":"","models":[]};配置了合成 key 和模型后,default 取第一个模型,列表里没有 default 项。
    • 定时任务:assistantModel 为空、timeoutMinutes=75 可以保存;"default" 加 241 返回 400「执行超时必须为 1–240 分钟」;"default" 加 30 能保存,模型被清空、超时为 30;指定模型不填超时时,保留该模型,超时默认 30。
  • GitHub 检查:core、browser、platform-required、e2e-required 等 16 项全部通过。

历史问题:上一轮没有阻塞问题。作者自己提的 P2(cachedCLIModels 跨账号顺序)的回归用例 TestCodeBuddyImplicitModelStaysWithItsAccount 仍然通过。

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.

2 participants