Skip to content

revert: remove built-in tool settings and mode availability - #5489

Merged
liruifengv merged 3 commits into
mainfrom
revert/5351-built-in-tool-settings
Nov 26, 2026
Merged

liruifengv merged 3 commits into
mainfrom
revert/5351-built-in-tool-settings

Conversation

@liruifengv

@liruifengv liruifengv commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Screenshots / Recordings

回退前(#5351 新增的设置入口与子页):

Before: Built-in tools settings added in #5351

回退后,「Settings → Agent & Sessions」与移动端设置面板不再显示「Built-in tools」入口,恢复 #5351 之前的设置页结构。本次未在本地启动 Electron 或浏览器自动化重新截图。

Requirement or Bug

回退 #5351(233b17fac):移除桌面端 / Web 设置中的内置工具开关、配套的 GET /api/v1/tools/catalog 与 /config tools 映射,以及 Plan / Swarm / Tower / Goal 在所需工具被禁用时的入口隐藏与服务端拦截。

#5351 尚未随任何正式版本发布,其两个 changeset 仍在 .changeset/ 中;本 PR 一并删除这两个未发布的 changeset,不新增 changeset。#5351 合入后其他 PR 的修复与重构保持不变。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路

基于最新 origin/main 对 233b17fac 执行 git revert,解决与后续提交产生的 5 处冲突:只摘除 #5351 引入的设置界面、目录接口、配置映射和模式可用性联动,保留后续 PR 引入的行为。全局 [tools] 策略对运行中 Agent、子 Agent 和新会话动态生效的引擎机制本身保持不变。

另外,#5351 顺手在 packages/kap-server/src/middleware/defineRoute.ts 抽出的 GetRouteHost / PostRouteHost 共享类型(纯类型提取,无运行时行为)予以保留;若一并回退,会在 7 个路由文件中恢复重复的局部 RouteHost 接口,触发 check:duplication 的 9 处新增重复。

同时按评审意见保留了 SettingsDialog 的 confirmDiscard 暴露与 App.vue 的快捷键/菜单关闭守卫(只检查 Global AGENTS.md 未保存草稿)。#5262(已随 Desktop 1.5.0 发布)引入 Global AGENTS.md 编辑页时只守住了弹窗自身的 requestClose() 与 Tab 切换,漏掉了快捷键/菜单直接关闭路径;#5351 曾顺手补上,本 PR 保留这部分守卫并补了回归测试与 kimi-code-app patch changeset。

 apps/desktop/src/renderer/          packages/app-components/src/settings/
-  SettingsDialog / MobileSettingsSheet / App.vue / ChatDock.vue
-  └── DefaultToolsPanel / DefaultToolsRow / DefaultToolsSetting / defaultToolsCatalog
 packages/app-core / app-client / app-components
-  ├── api: listToolCatalog、AppConfig.tools、agent 帧 *_mode_available 映射
-  └── composer: 按工具可用性过滤 /plan /swarm /goal /tower 菜单项与提交拦截
 packages/kap-server
-  ├── GET /api/v1/tools/catalog 与 POST /api/v1/config 的 tools 字段
-  ├── WS agent 帧与 /sessions/{id}/profile 的 *_mode_available 字段
-  └── SessionEventBroadcaster 在 tools / experimental 配置或会话工具策略变化时刷新 agent 帧
 packages/agent-core-v2
-  ├── 内置工具 userConfigurable 元数据
-  └── Plan / Swarm / Tower / Goal 进入(及恢复会话自动进 Plan)时的工具可用性守卫

冲突处理(保留的后续改动)

冲突文件 处理方式
apps/desktop/src/renderer/App.vue / SettingsDialog.vue 移除 DefaultToolsSetting 相关状态与守卫,保留仅针对 Global AGENTS.md 未保存草稿的 confirmDiscard 暴露与快捷键/菜单关闭守卫
apps/desktop/tests/renderer/settings-dialog-font-page.test.ts 将 #5351 的工具草稿 confirmDiscard 用例改为覆盖 Global AGENTS.md 未保存草稿(修复前失败、修复后通过),保留 #5204 新增的归档会话按项目分组与同名项目路径区分用例
packages/app-components/src/composer/Composer.vue 删除 disabled-command 提示分支,保留 #5443 的 isBlockedByProjectTrust(decision) 项目信任提交拦截
packages/kap-server/src/protocol/rest-config.ts 删除 toolsConfigSchema 与 tools 字段,保留 #5432 回同步的 configFieldsSchema + .extend() 结构
packages/kap-server/src/transport/ws/v1/sessionEventBroadcaster.ts 删除 ISessionToolPolicy 订阅及 tools / experimental 刷新触发,保留 #5206 的 IProjectService 命名,以及 #5449 在 models / providers 配置变化时刷新 agent 帧的逻辑
packages/kap-server/src/transport/ws/v1/agentState.ts / ws-agent.ts / sessionAgentFeed.ts 移除四个 *_mode_available 字段与 toolPolicy 读取,完整保留 #5449 的 profile_revision、missing_model、SessionAgentFeed.refresh() 及模型目录变化时的帧刷新
packages/kap-server/test/sessionEventBroadcaster.test.ts 移除 #5351 的 5 条模式可用性用例,保留 #5449 新增的「模型目录变化推送 agent 帧」用例,改用 model 字段(k2 → k3)验证刷新
packages/kap-server/test/apiSurface.test.ts 运行 pnpm qa:refresh schema 核对快照,HOST_CONTRACT.digest 更新为回退后的实际值,HOST_API_LEVEL 保持 1(被移除的接口与字段均未正式发布)
删除测试清单、原有覆盖与剩余保障

本次删除的测试均由 #5351 引入,覆盖的功能随本次回退整体移除:

  • apps/desktop/tests/renderer/chat-dock-goal.test.ts:覆盖 UpdateGoal 不可用时 ChatDock 的 Goal 恢复拦截与暂停可用性。
  • packages/app-components/test/defaultToolsPanel.test.ts:覆盖 DefaultToolsPanel / Row / Setting 的分组、草稿保存、并发更新 rebase、离开确认与加载失败重试。
  • packages/app-core/test/defaultTools.test.ts:覆盖 defaultTools.ts 对 [tools] allowlist / denylist 的解析与并发 rebase。
  • 既有测试文件中移除的 #5351 用例:工具草稿未保存拦截(settings-dialog-font-page.test.ts,由同文件新增的 Global AGENTS.md confirmDiscard 用例继续覆盖外部关闭守卫契约)、模式可用性帧与旧服务端回退(agentStateFrames.test.ts、mappers.test.ts)、菜单与提交拦截(composerSubmit.test.ts、composerRunningSendMode.test.ts、slashCommands.test.ts)、REST 目录与 tools 配置(configClient.test.ts、config.test.ts)、工具策略变化推送帧(sessionEventBroadcaster.test.ts)、各模式工具守卫(plan*.test.ts、goal*.test.ts、swarm.test.ts、tower*.test.ts、loop.test.ts)。

需要单独说明的一项:packages/kap-server/test/tools.test.ts 中的 applies global config changes to existing agents, subagents, and new sessions 由 #5351 新增,依赖本次一并移除的 POST /api/v1/config { tools }。引擎层「全局 [tools] 配置变更对已有 Agent 动态生效」的行为没有改动,仍由 packages/agent-core-v2/test/agent/toolPolicy/toolPolicyService.test.ts 覆盖;失去的仅是已回退的 REST tools 写入路径覆盖。

未删除任何已登记的 L0 用例 ID;[L0:kap.api-contract] 保留,契约快照随接口回退同步更新。

Behavior Changes and Affected Users

行为 回退前(#5351 后) 回退后 依赖旧行为的人群 逃生口
桌面端 / Web「Settings → Agent & Sessions → Built-in tools」(含移动端设置面板) 提供内置工具开关子页,保存后写入全局 [tools],未保存修改有离开确认 移除该入口与子页 在基于 main 的未发布桌面端 / Web 构建中使用该设置页的用户(正式版用户无感知) 直接在 config.toml 配置 [tools] 的 enabled / disabled
GET /api/v1/tools/catalog 无会话即可返回可配置内置工具目录 路由移除(404) 本仓设置页(已同步删除);在 main 构建上调用该接口的自定义客户端 在会话内通过 GET /api/v1/tools?session_id=... 查询工具及激活状态
POST /api/v1/config 的 tools 字段 校验并合并写入全局 [tools].enabled / disabled 恢复 #5351 前行为:schema 不声明 tools,该键被 Zod 剥离、不写入;GET /api/v1/config 仍按原逻辑透传 config.toml 中已有的 [tools] 通过 REST 修改 [tools] 的第一方设置页(已删除)或 main 构建上的外部调用方 直接编辑 config.toml 的 [tools] 段
WS agent 帧与 POST /sessions/{id}/profile 的 *_mode_available 字段 上报 plan_mode_available / swarm_mode_available / tower_mode_available / goal_mode_available;全局 [tools]、[experimental] 或会话工具策略变化时主动推送新 agent 帧 移除这四个字段,不再因工具策略变化额外推送 agent 帧(#5449 的 profile_revision、missing_model 及 models / providers / 模型目录变化推送保持不变) 桌面端 / Web 客户端(已同步移除消费逻辑);读取这些未发布字段的外部 WS 客户端 无(恢复 #5351 前帧结构,HOST_API_LEVEL 保持 1)
Global AGENTS.md 编辑中通过快捷键或菜单关闭设置弹窗 经 settingsDialogRef.confirmDiscard() 弹出丢弃确认(#5351 引入,同时守卫工具开关页与 Global AGENTS.md) 保留丢弃确认(仅针对 Global AGENTS.md;#5351 前的 1.5.0 正式版会直接关闭丢失草稿) 在 Settings → Custom instructions 编辑全局 AGENTS.md 的桌面端 / Web 用户 无(保留并固化 main 上的防误关行为)
桌面端 / Web 输入框 / 菜单与模式命令提交 所需工具被禁用时隐藏 /plan、/swarm、/goal、/tower 入口,手动输入进入命令时提示 composer.disabledCommand 且不发送 /plan、/swarm、/goal 始终显示(/tower 仍仅受实验开关控制);手动输入命令正常分发 禁用 ExitPlanMode / AgentSwarm / UpdateGoal / Tower 工具的桌面端与 Web 用户 无(恢复 #5351 前行为)
引擎模式进入守卫(Plan / Swarm / Tower / Goal 创建与恢复、会话启动时自动恢复 Plan) 所需工具被禁用时拒绝进入并报错(退出、暂停、取消仍可用) 不再因这些工具被禁用而拦截进入;被禁用工具本身仍不会提供给模型调用 在 [tools] 或 profile 中禁用上述工具的 TUI、desktop/web、KAP、ACP、SDK 用户 无(恢复 #5351 前行为,工具执行仍由既有 AgentToolPolicyService 控制)

受影响模块与验证:

  • packages/kap-server:apiSurface.test.ts(含 [L0:kap.api-contract] 与 HOST_CONTRACT 哈希)、config.test.ts、sessionEventBroadcaster.test.ts、tools.test.ts,以及 tsc --noEmit。
  • packages/agent-core-v2:features/plan、features/goal、features/swarm、features/tower、agent/loop 测试及 tsc --noEmit。
  • packages/app-core / app-client / app-components / apps/desktop:settings-dialog-font-page.test.ts、agentStateFrames.test.ts、composerSubmit.test.ts、composerRunningSendMode.test.ts、composerMenuViewportClamp.test.ts、composerUndoDraft.test.ts、configClient.test.ts、mappers.test.ts、slashCommands.test.ts,以及 kimi-code-app 类型检查(含渲染层 vue-tsc)。
  • 仓库检查:pnpm lint、pnpm run check:duplication origin/main。
  • 未验证:真实 Electron / 浏览器界面截图与人工交互;Windows 平台本地运行(改动不涉及路径、子进程、shell 或终端输入)。
实际运行的验证命令
  • pnpm exec tsc -p packages/agent-core-v2/tsconfig.json --noEmit
  • pnpm exec tsc -p packages/kap-server/tsconfig.json --noEmit
  • pnpm --filter kimi-code-app run typecheck
  • pnpm qa:refresh schema(快照一致,HOST_CONTRACT 哈希更新后复跑 apiSurface.test.ts 通过)
  • pnpm exec vitest run --reporter=agent --maxWorkers=4 <上述 36 个受影响测试文件/目录>(36 files / 1315 tests 全部通过)
  • 合并 origin/main(含 #5449、#5483、#5450)后复跑:kap-server 与 kimi-code-app 类型检查,以及 apiSurface、sessionEventBroadcaster、sessions、tools、config、agentStateFrames、modelSwitchConfirm、modelSwitchConfirmGate、composerSubmit、tests/scenarios/conversation.test.ts(10 files / 449 tests 全部通过)
  • Global AGENTS.md 关闭守卫修复后复跑:settings-dialog-font-page.test.ts(新增用例在修复前失败,修复后 5/5 通过)及 kimi-code-app 类型检查
  • pnpm lint
  • pnpm run check:duplication origin/main

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 55e9da1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kimi-code-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T05:32:11.079009Z 55e9da1 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@55e9da1
npx https://pkg.pr.new/@moonshot-ai/kimi-code@55e9da1

commit: 55e9da1

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 44ea9a7118

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/desktop/src/renderer/App.vue Resolved
Keep profile_revision, missing_model, and SessionAgentFeed.refresh() from #5449 so models/providers config changes and model catalog updates still push agent frames, while dropping the reverted #5351 mode availability fields and tool policy subscriptions.
@liruifengv

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 55e9da1355

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@liruifengv
liruifengv merged commit c33c8b2 into main Nov 26, 2026
23 checks passed
@liruifengv
liruifengv deleted the revert/5351-built-in-tool-settings branch November 26, 2026 05:37
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 26, 2026
Compaction (MoonshotAI#5538):
- Send the whole history to the summary request, drop the pre-shrink and
  the drop-oldest retries, shrink a truncated summary only when the window
  squeezed its output, and retry empty or thinking-only summaries with the
  same history. Keep flushReminders, applyCompactionRound and
  historyFromContextPreservingToolNotes.
- Fix two pre-existing 2.7-alignment gaps the suite exposed: recognise the
  serialized { kind: 'context_overflow' } payload in
  shouldRecoverFromContextOverflow, and remove the duplicate
  runWithCredentialRecovery around the requester's own credential recovery
  so a replayed 401 surfaces instead of being retried.
- fullCompaction 124 pass / 0 fail; agent-core-v2 typecheck clean.

Built-in tool settings (MoonshotAI#5489):
- Keep MoonshotAI#5351's KAP catalog/config/agent-state fields, the four mode guards
  and the desktop/Web UI as a fork-only capability.
- Replace the 22 per-tool userConfigurable flags with the central
  USER_CONFIGURABLE_BUILTIN_TOOL_NAMES list in kap-server. The catalog still
  returns the same 39 entries (26 core + 13 Tower), now pinned by
  tools.test.ts.
- Ledger: MoonshotAI#5351 marked fork-only, MoonshotAI#5489 not-applicable with the keep-both
  approval, both in B2; the PLAYBOOK records the invariant.
- kap-server tools 8 pass; agent-core-v2 and kap-server typecheck clean.

Loop baseline:
- max_steps no longer marks a completed step as interrupted.
- Goal creation accepts UpdateGoal when it is loadable through
  isToolActiveForDisclosure.
- Refresh the three loop inline snapshots for the intentional
  continuation, loadable-tools and step.begin shape.
- test/agent/loop 175 pass / 3 fail; the three remaining failures are the
  pre-existing cancelled-partial preservation, recorded as the first
  acceptance of the MoonshotAI#5541 requester migration.

Ledger refresh adds 87 upstream rows; MoonshotAI#5538 and MoonshotAI#5489 are triaged, 85 remain
pending.
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